@tunasand/sdk 0.8.0 → 0.12.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 (221) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +165 -144
  3. package/dist/analytics.js +183 -109
  4. package/dist/app.js +276 -166
  5. package/dist/apps-BysPfMuR.js +408 -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-C2Bl-OAF.js +80 -0
  14. package/dist/bridge.js +1 -13
  15. package/dist/build-file-DNi0PHC5.js +31 -0
  16. package/dist/cli.js +6212 -8
  17. package/dist/{client-Derrexwr.js → client-C8STAw9T.js} +43 -24
  18. package/dist/code-N8pBUDbq.js +30 -0
  19. package/dist/code.d.ts +1 -0
  20. package/dist/code.js +1 -0
  21. package/dist/collection-26aglrg6.js +282 -0
  22. package/dist/{declared-DuNMsdXw.js → declared-CE4a61qb.js} +35 -35
  23. package/dist/delivery.js +121 -114
  24. package/dist/dev-operations-Tutwi1On.js +46 -0
  25. package/dist/dev.js +9 -16
  26. package/dist/embeds-DY6O5TrJ.js +29 -0
  27. package/dist/end-users.d.ts +1 -0
  28. package/dist/end-users.js +189 -0
  29. package/dist/endUsers-DODfjnv1.js +77 -0
  30. package/dist/{errorLabels-BgtQ_zUn.js → errorLabels-BK1NJ6Wz.js} +374 -238
  31. package/dist/i18n.js +4 -4
  32. package/dist/ids-DmtIoqBX.js +109 -0
  33. package/dist/integrations.js +95 -24
  34. package/dist/{ja-Du6ooL6i.js → ja-B3lAaOhZ.js} +91 -45
  35. package/dist/{ja-CeHU0EaY.js → ja-axQPxMJ-.js} +3 -3
  36. package/dist/operations-CIB99rIY.js +95 -0
  37. package/dist/operations.d.ts +1 -0
  38. package/dist/operations.js +1 -0
  39. package/dist/{page-Bzrj24sJ.js → page-yo1cw1kW.js} +1 -1
  40. package/dist/paymentPort-p1jV44Zz.js +203 -0
  41. package/dist/preview.js +8 -1
  42. package/dist/{profile-1em_lcxq.js → profile-DBsXLvvI.js} +48 -48
  43. package/dist/rich-text.js +16 -16
  44. package/dist/{schema-WnobuwLg.js → schema-Bs_BUUNv.js} +526 -265
  45. package/dist/schema.js +66 -88
  46. package/dist/types/access/src/handoff.d.ts +19 -14
  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/oidc.d.ts +12 -2
  50. package/dist/types/access/src/signed.d.ts +0 -2
  51. package/dist/types/adapter-cloudflare/src/eventLog/viewSchema.d.ts +11 -0
  52. package/dist/types/contract/src/accountProfile.d.ts +7 -0
  53. package/dist/types/contract/src/api/define.d.ts +165 -0
  54. package/dist/types/contract/src/apiKeys.d.ts +6 -2
  55. package/dist/types/contract/src/app.d.ts +32 -7
  56. package/dist/types/contract/src/appChannels.d.ts +152 -0
  57. package/dist/types/contract/src/appDefinition.d.ts +11 -5
  58. package/dist/types/contract/src/appDependencies.d.ts +107 -24
  59. package/dist/types/contract/src/appIdentities.d.ts +21 -0
  60. package/dist/types/contract/src/appInbound.d.ts +53 -0
  61. package/dist/types/contract/src/appMail.d.ts +106 -0
  62. package/dist/types/contract/src/appSecrets.d.ts +63 -0
  63. package/dist/types/contract/src/appServer.d.ts +460 -45
  64. package/dist/types/contract/src/approvals.d.ts +1 -1
  65. package/dist/types/contract/src/apps.d.ts +126 -60
  66. package/dist/types/contract/src/auditActions.d.ts +2 -2
  67. package/dist/types/contract/src/auditLabels.d.ts +120 -15
  68. package/dist/types/contract/src/authorize.d.ts +42 -14
  69. package/dist/types/contract/src/bridge.d.ts +35 -36
  70. package/dist/types/contract/src/consents.d.ts +29 -27
  71. package/dist/types/contract/src/deletion.d.ts +18 -0
  72. package/dist/types/contract/src/embeds.d.ts +26 -90
  73. package/dist/types/contract/src/{customerLabels.d.ts → endUserLabels.d.ts} +6 -9
  74. package/dist/types/contract/src/endUsers.d.ts +244 -0
  75. package/dist/types/contract/src/errorLabels.d.ts +67 -37
  76. package/dist/types/contract/src/errorLabelsEn.d.ts +50 -33
  77. package/dist/types/contract/src/errors.d.ts +28 -16
  78. package/dist/types/contract/src/eventSchemas.d.ts +70 -0
  79. package/dist/types/contract/src/eventTraces.d.ts +41 -0
  80. package/dist/types/contract/src/failureStatus.d.ts +14 -22
  81. package/dist/types/contract/src/fieldAccess.d.ts +8 -8
  82. package/dist/types/contract/src/formLabels.d.ts +3 -0
  83. package/dist/types/contract/src/forms.d.ts +4 -0
  84. package/dist/types/contract/src/grants.d.ts +26 -0
  85. package/dist/types/contract/src/headers.d.ts +5 -0
  86. package/dist/types/contract/src/hostingRpc.d.ts +44 -19
  87. package/dist/types/contract/src/identifiers.d.ts +45 -17
  88. package/dist/types/contract/src/ids.d.ts +18 -10
  89. package/dist/types/contract/src/import.d.ts +17 -16
  90. package/dist/types/contract/src/index.d.ts +57 -29
  91. package/dist/types/contract/src/integrationGraph.d.ts +83 -0
  92. package/dist/types/contract/src/issueLabels.d.ts +121 -81
  93. package/dist/types/contract/src/issueLabelsEn.d.ts +61 -41
  94. package/dist/types/contract/src/manage.d.ts +16 -7
  95. package/dist/types/contract/src/manageLabels.d.ts +2 -0
  96. package/dist/types/contract/src/manifestText.d.ts +66 -0
  97. package/dist/types/contract/src/messagePort.d.ts +208 -0
  98. package/dist/types/contract/src/migration.d.ts +2 -2
  99. package/dist/types/contract/src/notices.d.ts +37 -0
  100. package/dist/types/contract/src/operationEffects.d.ts +39 -0
  101. package/dist/types/contract/src/operatorOperations.d.ts +104 -110
  102. package/dist/types/contract/src/outbound.d.ts +29 -0
  103. package/dist/types/contract/src/paths.d.ts +13 -0
  104. package/dist/types/contract/src/paymentPort.d.ts +129 -0
  105. package/dist/types/contract/src/pending.d.ts +2 -0
  106. package/dist/types/contract/src/permissions.d.ts +7 -11
  107. package/dist/types/contract/src/perspective.d.ts +26 -0
  108. package/dist/types/contract/src/powers.d.ts +5 -0
  109. package/dist/types/contract/src/principal.d.ts +127 -56
  110. package/dist/types/contract/src/readPages.d.ts +92 -0
  111. package/dist/types/contract/src/recordLabels.d.ts +6 -0
  112. package/dist/types/contract/src/roles.d.ts +7 -4
  113. package/dist/types/contract/src/ruleLabels.d.ts +16 -0
  114. package/dist/types/contract/src/ruleProblems.d.ts +16 -0
  115. package/dist/types/contract/src/schemaLabels.d.ts +8 -0
  116. package/dist/types/contract/src/settingProblems.d.ts +18 -1
  117. package/dist/types/contract/src/settings.d.ts +5 -7
  118. package/dist/types/contract/src/siteDeclaration.d.ts +7 -7
  119. package/dist/types/contract/src/siteIndex.d.ts +76 -0
  120. package/dist/types/contract/src/transfer.d.ts +1 -1
  121. package/dist/types/contract/src/trial.d.ts +4 -1
  122. package/dist/types/contract/src/versions.d.ts +1 -3
  123. package/dist/types/contract/src/viewEvent.d.ts +0 -9
  124. package/dist/types/contract/src/webhooks.d.ts +24 -3
  125. package/dist/types/contract/src/workflow.d.ts +16 -19
  126. package/dist/types/contract/src/workspaceItems.d.ts +23 -7
  127. package/dist/types/contract/src/workspacePaths.d.ts +1 -1
  128. package/dist/types/rich-text/src/html.d.ts +1 -1
  129. package/dist/types/rich-text/src/index.d.ts +8 -7
  130. package/dist/types/rich-text/src/labels/en.d.ts +1 -1
  131. package/dist/types/rich-text/src/labels/ja.d.ts +2 -2
  132. package/dist/types/rich-text/src/library.d.ts +1 -1
  133. package/dist/types/rich-text/src/media.d.ts +2 -0
  134. package/dist/types/rich-text/src/normalize.d.ts +1 -1
  135. package/dist/types/rich-text/src/problems.d.ts +5 -5
  136. package/dist/types/rich-text/src/profile.d.ts +10 -10
  137. package/dist/types/rich-text/src/render.d.ts +1 -1
  138. package/dist/types/rich-text/src/schema.d.ts +2 -2
  139. package/dist/types/rich-text/src/standard.d.ts +4 -4
  140. package/dist/types/rich-text/src/types.d.ts +2 -2
  141. package/dist/types/schema/src/audience.d.ts +1 -3
  142. package/dist/types/schema/src/capabilities.d.ts +18 -27
  143. package/dist/types/schema/src/changes.d.ts +3 -1
  144. package/dist/types/schema/src/collection.d.ts +142 -111
  145. package/dist/types/schema/src/defaultSchema.d.ts +8 -2
  146. package/dist/types/schema/src/fieldIds.d.ts +18 -0
  147. package/dist/types/schema/src/file.d.ts +24 -11
  148. package/dist/types/schema/src/fileRefs.d.ts +14 -0
  149. package/dist/types/schema/src/fileSignature.d.ts +20 -0
  150. package/dist/types/schema/src/filesCollection.d.ts +7 -0
  151. package/dist/types/schema/src/forms.d.ts +43 -0
  152. package/dist/types/schema/src/imageMetadata.d.ts +9 -0
  153. package/dist/types/schema/src/index.d.ts +19 -10
  154. package/dist/types/schema/src/indexes.d.ts +11 -0
  155. package/dist/types/schema/src/input.d.ts +1 -1
  156. package/dist/types/schema/src/integrity.d.ts +8 -7
  157. package/dist/types/schema/src/kinds.d.ts +26 -0
  158. package/dist/types/schema/src/labels/en.d.ts +89 -46
  159. package/dist/types/schema/src/labels/ja.d.ts +92 -46
  160. package/dist/types/schema/src/mediaUrl.d.ts +26 -33
  161. package/dist/types/schema/src/page.d.ts +4 -4
  162. package/dist/types/schema/src/problems.d.ts +85 -42
  163. package/dist/types/schema/src/refs.d.ts +0 -9
  164. package/dist/types/schema/src/schema.d.ts +17 -12
  165. package/dist/types/schema/src/selfOps.d.ts +20 -19
  166. package/dist/types/schema/src/traits.d.ts +28 -0
  167. package/dist/types/schema/src/typesSource.d.ts +1 -1
  168. package/dist/types/schema/src/values.d.ts +5 -2
  169. package/dist/types/schema/src/widening.d.ts +3 -0
  170. package/dist/types/sdk/src/analytics.d.ts +2 -1
  171. package/dist/types/sdk/src/app.d.ts +43 -14
  172. package/dist/types/sdk/src/astro-image.d.ts +19 -0
  173. package/dist/types/sdk/src/astro-response.d.ts +6 -0
  174. package/dist/types/sdk/src/astro-server.d.ts +16 -0
  175. package/dist/types/sdk/src/astro.d.ts +19 -0
  176. package/dist/types/sdk/src/bridge.d.ts +2 -4
  177. package/dist/types/sdk/src/code.d.ts +61 -0
  178. package/dist/types/sdk/src/delegation.d.ts +13 -3
  179. package/dist/types/sdk/src/delivery/changes.d.ts +4 -4
  180. package/dist/types/sdk/src/delivery/client.d.ts +33 -22
  181. package/dist/types/sdk/src/delivery/fields.d.ts +3 -3
  182. package/dist/types/sdk/src/delivery/index.d.ts +3 -3
  183. package/dist/types/sdk/src/delivery/media.d.ts +5 -8
  184. package/dist/types/sdk/src/delivery/query.d.ts +15 -11
  185. package/dist/types/sdk/src/delivery/schema.d.ts +1 -1
  186. package/dist/types/sdk/src/delivery/values.d.ts +10 -14
  187. package/dist/types/sdk/src/delivery.d.ts +2 -2
  188. package/dist/types/sdk/src/dev-operations.d.ts +20 -0
  189. package/dist/types/sdk/src/dev.d.ts +6 -5
  190. package/dist/types/sdk/src/end-users.d.ts +187 -0
  191. package/dist/types/sdk/src/i18n.d.ts +2 -2
  192. package/dist/types/sdk/src/integrations.d.ts +14 -21
  193. package/dist/types/sdk/src/operations.d.ts +17 -0
  194. package/dist/types/sdk/src/preview.d.ts +2 -1
  195. package/dist/types/sdk/src/rich-text.d.ts +2 -2
  196. package/dist/types/sdk/src/schema.d.ts +1 -1
  197. package/dist/types/sdk/src/site/artifact.d.ts +64 -0
  198. package/dist/types/sdk/src/site/build-file.d.ts +30 -0
  199. package/dist/types/sdk/src/site/check-code.d.ts +14 -0
  200. package/dist/types/sdk/src/site/check-text.d.ts +19 -0
  201. package/dist/types/sdk/src/site/cli.d.ts +52 -0
  202. package/dist/types/sdk/src/site/content-type.d.ts +2 -0
  203. package/dist/types/sdk/src/site/labels.d.ts +14 -0
  204. package/dist/types/sdk/src/types.d.ts +1 -1
  205. package/dist/{types-B77qvqPJ.js → types-CYnY-63C.js} +5 -6
  206. package/dist/types.js +1 -1
  207. package/dist/{typesSource-CWybQYus.js → typesSource-BTA9-rcB.js} +17 -15
  208. package/package.json +32 -6
  209. package/dist/apps-BxnJ1RlU.js +0 -435
  210. package/dist/bridge-DtHw9hS6.js +0 -74
  211. package/dist/collection-BEOxeISR.js +0 -189
  212. package/dist/customers-DTbL0qn6.js +0 -86
  213. package/dist/customers.d.ts +0 -1
  214. package/dist/customers.js +0 -185
  215. package/dist/embeds-B5V54Zur.js +0 -34
  216. package/dist/ids--RF7hGyC.js +0 -36
  217. package/dist/src-sazhzYui.js +0 -71
  218. package/dist/types/contract/src/customers.d.ts +0 -266
  219. package/dist/types/schema/src/legacy.d.ts +0 -2
  220. package/dist/types/schema/src/media.d.ts +0 -5
  221. package/dist/types/sdk/src/customers.d.ts +0 -184
@@ -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,4 +1,4 @@
1
- import { type BridgeApiMethod, type BridgeContext, type BridgeDialogSize, type BridgeError, type BridgeEventName, type BridgeEvents, type BridgeResults, type BridgeTarget, type BridgeToastTone } from '../../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
2
  export { BRIDGE_API_METHODS, BRIDGE_ERRORS, BRIDGE_NAMESPACE, BRIDGE_THEME_TOKENS, BRIDGE_THEME_VAR_PREFIX, BRIDGE_VERSION } from '../../contract/src/bridge.js';
3
3
  export type { BridgeApiMethod, BridgeContext, BridgeDialogSize, BridgeError, BridgeEventName, BridgeEvents, BridgeRequestKind, BridgeRequests, BridgeResults, BridgeTarget, BridgeTheme, BridgeThemeToken, BridgeToastTone } from '../../contract/src/bridge.js';
4
4
  /** 依頼の失敗(code は理由) */
@@ -52,8 +52,6 @@ export type Bridge = Readonly<{
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` に付ける
@@ -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;
@@ -1,10 +1,10 @@
1
- /** 交換の秘密鍵(ES256 の JWK の秘密鍵、kid は登録した公開鍵の kid) */
1
+ /** 交換の秘密鍵(ES256 か ML-DSA-44 の JWK の秘密鍵、kid は登録した公開鍵の kid) */
2
2
  export type AppSigningKey = Readonly<{
3
3
  jwk: JsonWebKey & {
4
4
  kid?: string;
5
5
  };
6
6
  }>;
7
- /** アプリの JWT(iss はアプリの ID、aud は環境の CMS の URL) */
7
+ /** アプリの JWT(iss はアプリの ID、aud は配信の基点) */
8
8
  export declare function appAssertion(key: AppSigningKey, claims: Readonly<{
9
9
  appId: string;
10
10
  audience: string;
@@ -17,6 +17,14 @@ export type DelegationExchange = Readonly<{
17
17
  delegation: string;
18
18
  fetch?: (request: Request) => Promise<Response>;
19
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
+ }>;
20
28
  /** 交換の結果(error は OAuth の error の値か、応答が形に合わない upstream) */
21
29
  export type DelegationExchangeResult = Readonly<{
22
30
  ok: true;
@@ -28,7 +36,9 @@ export type DelegationExchangeResult = Readonly<{
28
36
  status: number;
29
37
  }>;
30
38
  /** 代理の委任の主張をアカウントの資格のトークンに替える */
31
- export declare function exchangeDelegation(input: DelegationExchange): Promise<DelegationExchangeResult>;
39
+ export declare const exchangeDelegation: (input: DelegationExchange) => Promise<DelegationExchangeResult>;
40
+ /** 画面のトークンをアカウントの資格のトークンに替える(結果の形は exchangeDelegation と同じ) */
41
+ export declare const exchangeSessionToken: (input: SessionTokenExchange) => Promise<DelegationExchangeResult>;
32
42
  /** アカウントの資格のトークンで管理 API を呼ぶクライアント(path は /api の下、base は環境の CMS の URL) */
33
43
  export declare const bearerClient: (input: Readonly<{
34
44
  base: string;
@@ -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
1
  import type { Collection } from '../../../schema/src/index.js';
2
- import { type ListQuery, type Page } from './query.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,40 +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
69
  format?: import("../../../schema/src/collection.js").ContentFormat;
66
- publishing?: import("../../../schema/src/collection.js").Publishing;
70
+ publication?: boolean;
67
71
  fields: readonly import("../schema.js").FieldDef[];
68
72
  pages?: readonly import("../schema.js").PageDef[];
69
73
  counts?: readonly import("../../../schema/src/collection.js").CountDef[];
70
74
  og?: string;
71
- slugMode?: import("../../../schema/src/collection.js").SlugMode;
75
+ slug_mode?: import("../../../schema/src/collection.js").SlugMode;
72
76
  roles?: import("../../../schema/src/collection.js").FieldRoles;
73
- grant?: string;
77
+ entitlement?: string;
74
78
  private?: boolean;
75
79
  unique?: readonly import("../../../schema/src/integrity.js").UniqueDef[];
76
- selfOps?: readonly import("../../../schema/src/collection.js").SelfOp[];
77
- retentionDays?: number;
78
- publishChecks?: readonly string[];
79
- }>>(path: string, query: ListQuery<T> & Readonly<{
80
- limit: number;
81
- }>) => Promise<Page<I>>;
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>>;
82
93
  prefetch: (paths: readonly string[], { ifNoneMatch }?: {
83
94
  ifNoneMatch?: string;
84
95
  }) => Promise<Prefetched>;
@@ -1,5 +1,5 @@
1
1
  import type { CollectionSchema, Collection, FieldDef } from '../../../schema/src/index.js';
2
- import type { GrantedField, FieldsOf, FieldValue, ItemMeta, ItemOf, UndeliveredField } from './values.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>, {
@@ -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 DeliveredFile, type ImageParams, type MediaPath } from '../../../schema/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,18 +1,15 @@
1
1
  import { type CropRect, type Media } from '../../../schema/src/index.js';
2
- /** 実体の配信の URL の材料(project はプロジェクトの ID(base32)、id は実体の ID(UUID)。width・height は画像の元の画素) */
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
- * - パスのプロジェクトは base32 の正の形、実体は UUID。配信 API の url と同じ値になる
13
- * - 配信しない形式、ID の形が違うとき(プロジェクトの UUID の形を含む)は 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) */
@@ -1,6 +1,6 @@
1
1
  import type { Collection, FieldDef } from '../../../schema/src/index.js';
2
2
  import type { FieldPath } from './fields.js';
3
- import type { GrantedField, FieldsOf, Item, SingleValue, UndeliveredField } from './values.js';
3
+ import type { EntitledField, FieldsOf, Item, SingleValue, UndeliveredField } from './values.js';
4
4
  /** 範囲の指定(両端を含む) */
5
5
  type Range<V> = Readonly<{
6
6
  gte?: V;
@@ -16,7 +16,7 @@ type Ops<V, O extends FilterOp> = Readonly<{
16
16
  /** 絞り込みの演算(サーバーが実装する範囲) */
17
17
  type FilterOp = 'eq' | 'ne' | 'in' | 'gte' | 'lte' | 'begins' | 'exists';
18
18
  /** 項目の種類ごとの絞り込みの値(値だけの指定は一致) */
19
- type FilterValue<F extends FieldDef> = F extends UndeliveredField | GrantedField ? never : F extends {
19
+ type FilterValue<F extends FieldDef> = F extends UndeliveredField | EntitledField ? never : F extends {
20
20
  type: 'select' | 'reference';
21
21
  multiple: true;
22
22
  } ? Scalar<F> | Ops<Scalar<F>, 'eq' | 'in'> : F extends {
@@ -24,7 +24,7 @@ type FilterValue<F extends FieldDef> = F extends UndeliveredField | GrantedField
24
24
  } ? never : F extends {
25
25
  type: 'text';
26
26
  } ? string | Ops<string, 'eq' | 'ne' | 'in' | 'begins' | 'exists'> : F extends {
27
- type: 'select' | 'reference';
27
+ type: 'select' | 'status' | 'reference';
28
28
  } ? Scalar<F> | Ops<Scalar<F>, 'eq' | 'ne' | 'in' | 'exists'> : F extends {
29
29
  type: 'boolean';
30
30
  } ? boolean : F extends {
@@ -33,10 +33,10 @@ type FilterValue<F extends FieldDef> = F extends UndeliveredField | GrantedField
33
33
  type: 'datetime';
34
34
  } ? Ops<string, 'gte' | 'lte' | 'exists'> : never;
35
35
  /** 並べ替えできる項目の key(単数の文字・数値・日付・日時・選択肢・チェックボックス) */
36
- type SortableKey<T extends Collection> = FieldsOf<T> extends infer F ? (F extends UndeliveredField | GrantedField | {
36
+ type SortableKey<T extends Collection> = FieldsOf<T> extends infer F ? (F extends UndeliveredField | EntitledField | {
37
37
  multiple: true;
38
38
  } ? never : F extends {
39
- type: 'text' | 'number' | 'date' | 'datetime' | 'select' | 'boolean';
39
+ type: 'text' | 'number' | 'date' | 'datetime' | 'select' | 'status' | 'boolean';
40
40
  key: infer K extends string;
41
41
  } ? K : never) : never;
42
42
  /** 並べ替えの key(項目・公開日時・作成日時・更新日時・id) */
@@ -52,7 +52,7 @@ export type ListFilter<T extends Collection = Collection> = Readonly<{
52
52
  /**
53
53
  * コレクションの一覧の指定
54
54
  * - limit: 1ページの件数(サーバーの上限は100)
55
- * - cursor: 前のページの next
55
+ * - cursor: 前のページの next_cursor
56
56
  * - order: 並べ替えの key の配列(`-` の接頭辞で降順、最後に id を自動で追加)
57
57
  * - ids: レコードの id のいずれか(100個まで、順は order の順)
58
58
  * - fields: 返す項目と展開する参照(id は常に返す、展開は深さ1)
@@ -66,10 +66,10 @@ export type ListQuery<T extends Collection = Collection> = Readonly<{
66
66
  fields?: readonly FieldPath<T>[];
67
67
  filter?: ListFilter<T>;
68
68
  }>;
69
- /** ページ送りの応答(next は次のページの cursor、最後のページは null) */
69
+ /** ページ送りの応答(next_cursor は次のページの cursor、最後のページは null) */
70
70
  export type Page<I = Item> = Readonly<{
71
- items: readonly I[];
72
- next: string | null;
71
+ data: readonly I[];
72
+ next_cursor: string | null;
73
73
  }>;
74
74
  /** どのコレクションの一覧の指定も受け取る形(型の検査は ListQuery の側) */
75
75
  type QueryShape = Readonly<{
@@ -80,6 +80,10 @@ type QueryShape = Readonly<{
80
80
  fields?: readonly string[];
81
81
  filter?: Readonly<Record<string, unknown>>;
82
82
  }>;
83
- /** 一覧の指定をクエリの組に(find・get・subPath の params、一式の path に使用、1件の取得の fields にも使用) */
84
- export declare function listParams(query: QueryShape): Record<string, string>;
83
+ /** クエリの組(配列の値はパラメーターの繰り返し) */
84
+ export type QueryParams = Readonly<Record<string, string | readonly string[]>>;
85
+ /** クエリの組から URLSearchParams(配列の値は同じ名前で繰り返す) */
86
+ export declare const searchParamsOf: (params: QueryParams) => URLSearchParams;
87
+ /** 一覧の指定をクエリの組に(find・get・subPath の params、一式の path に使用、1件の取得の fields にも使用。in と ids はパラメーターの繰り返し) */
88
+ export declare function listParams(query: QueryShape): QueryParams;
85
89
  export {};
@@ -4,7 +4,7 @@ export declare const optionLabels: <K extends string = string>(schema: Collectio
4
4
  /** コレクションの項目(なければ例外: 導入先の設定の誤り) */
5
5
  export declare function fieldOf(schema: CollectionSchema, collection: string, key: string): FieldDef;
6
6
  /** 項目の宣言の上限(宣言がなければ例外) */
7
- export declare function limitOf(field: FieldDef, name: 'maxItems' | 'maxLength'): number;
7
+ export declare function limitOf(field: FieldDef, name: 'max_items' | 'max_length'): number;
8
8
  /** ページのパス(コレクションの宣言 pages から、ページのないコレクションは例外) */
9
9
  export declare function pagePath(schema: CollectionSchema, collection: string, record: PageRecord): string;
10
10
  /** プロジェクトのタイムゾーンでの日時の変換(表示用の日付と日時の組 dated を含む) */
@@ -19,7 +19,7 @@ export type SingleValue<F extends FieldDef> = F extends {
19
19
  } ? DateString : F extends {
20
20
  type: 'datetime';
21
21
  } ? string : F extends {
22
- type: 'select';
22
+ type: 'select' | 'status';
23
23
  options: readonly (infer O extends {
24
24
  value: string;
25
25
  })[];
@@ -30,7 +30,7 @@ export type SingleValue<F extends FieldDef> = F extends {
30
30
  } ? DeliveredFile | null : F extends {
31
31
  type: 'rich_text';
32
32
  } ? Body<DeliveredFile | null> : F extends {
33
- type: 'group';
33
+ type: 'object';
34
34
  fields: readonly (infer G extends FieldDef)[];
35
35
  } ? GroupValue<G> : unknown;
36
36
  /** まとまりの値(中の項目の key ごと) */
@@ -47,21 +47,17 @@ export type FieldValue<F extends FieldDef> = (F extends {
47
47
  } ? readonly SingleValue<F>[] : SingleValue<F>) | null;
48
48
  /** コレクションの項目 */
49
49
  export type FieldsOf<T extends Collection> = T['fields'][number];
50
- /** アクセス権の項目の宣言(旧い印 customersOnly も) */
51
- export type GrantedField = {
52
- audience: 'granted';
53
- } | {
54
- customersOnly: true;
50
+ /** アクセス権の項目の宣言 */
51
+ export type EntitledField = {
52
+ audience: 'entitled';
55
53
  };
56
- /** 配信しない項目の宣言(本人とスタッフ、旧い印 private も) */
54
+ /** 配信しない項目の宣言(本人とスタッフ) */
57
55
  export type UndeliveredField = {
58
- audience: 'self' | 'staff';
59
- } | {
60
- private: true;
56
+ audience: 'self' | 'none';
61
57
  };
62
58
  /**
63
59
  * 1件のメタ情報(作成・更新の日時、公開日時は公開の管理があるコレクションだけで未公開は null、日時は `ISO 8601` の UTC)
64
- * - requires: 顧客の出し分けの宣言があるコレクションだけ。顧客だけの項目を見るのに要る権利の対象のレコードの id で、空は有効な権利を1つでも持つ人
60
+ * - requires: エンドユーザーの出し分けの宣言があるコレクションだけ。エンドユーザーだけの項目を見るのに要る権利の対象のレコードの id で、空は有効な権利を1つでも持つ人
65
61
  */
66
62
  export type ItemMeta = Readonly<{
67
63
  created_at: string;
@@ -75,8 +71,8 @@ export type ItemOf<T extends Collection> = Readonly<{
75
71
  slug: string;
76
72
  _meta: ItemMeta;
77
73
  } & {
78
- [F in Exclude<FieldsOf<T>, GrantedField> as F['key']]: FieldValue<F>;
74
+ [F in Exclude<FieldsOf<T>, EntitledField> as F['key']]: FieldValue<F>;
79
75
  } & {
80
- [F in Extract<FieldsOf<T>, GrantedField> as F['key']]?: FieldValue<F>;
76
+ [F in Extract<FieldsOf<T>, EntitledField> as F['key']]?: FieldValue<F>;
81
77
  }>;
82
78
  export {};
@@ -1,3 +1,3 @@
1
- export { cachedDelivery, createDeliveryClient, createDeliveryClock, deliveredImageUrl, mediaUrlOf, DELIVERY_PATH, DeliveryError, fieldOf, imageParamsOf, limitOf, listParams, mediaOf, memoryDeliveryCache, optionLabels, pagePath, parseMediaPath, readChanges, signMediaUrl, subPath, withImageParams } from './delivery/index.js';
1
+ export { cachedDelivery, createDeliveryClient, createDeliveryClock, deliveredImageUrl, mediaUrlOf, DeliveryError, fieldOf, imageParamsOf, limitOf, listParams, mediaOf, memoryDeliveryCache, optionLabels, pagePath, parseMediaPath, readChanges, recordsPath, SIGNATURE_MAX_TTL_SEC, signMediaUrl, subPath, withImageParams } from './delivery/index.js';
2
2
  export type { Issue, IssueSeverity } from '../../contract/src/errors.js';
3
- export type { BundleResult, Change, ChangesPage, DeliveredFile, Delivery, DeliveryCache, DeliveryClient, DeliveryClock, FieldValue, ImageParams, ImageUrl, MediaUrlInput, Item, ItemMeta, ItemOf, FieldPath, ListFilter, ListQuery, MediaOf, MediaPath, Page, Prefetched, RecordRef, Selected } from './delivery/index.js';
3
+ export type { BundleResult, Change, ChangesPage, DeliveredFile, Delivery, DeliveryCache, DeliveryClient, DeliveryClock, FieldValue, ImageParams, ImageUrl, MediaUrlInput, Item, ItemMeta, ItemOf, FieldPath, ListFilter, ListQuery, MediaOf, MediaPath, Page, Prefetched, QueryParams, RecordRef, Selected, SignatureScope } from './delivery/index.js';
@@ -0,0 +1,20 @@
1
+ import type { CodeOperations } from './code.js';
2
+ /** 記録の1件 */
3
+ export type OperationFixture = Readonly<{
4
+ name: string;
5
+ input: unknown;
6
+ }> & (Readonly<{
7
+ returns: 'json';
8
+ result: unknown;
9
+ }> | Readonly<{
10
+ returns: 'bytes';
11
+ status: number;
12
+ headers: Readonly<Record<string, string>>;
13
+ body: string;
14
+ }>);
15
+ /** 記録のファイルの名前(操作の名前、種類、入力のハッシュ) */
16
+ export declare const operationFixtureName: (name: string, returns: OperationFixture["returns"], input?: unknown) => string;
17
+ /** ディレクトリの記録の全部 */
18
+ export declare const operationFixtures: (dir: string) => readonly OperationFixture[];
19
+ /** 記録を再生する操作(記録は呼ぶたびに読む) */
20
+ export declare function fixtureOperations(dir: string): CodeOperations;
@@ -11,15 +11,15 @@ export type FixtureResponse = Readonly<{
11
11
  export declare const fixtureName: (method: string, path: string, ifNoneMatch?: string, body?: string) => string;
12
12
  /** 記録の再生(port Delivery、dir は記録のディレクトリ) */
13
13
  export declare function fixtureDelivery(dir: string | URL): Delivery;
14
- /** 公開の配信 API の中継先(origin はプロジェクトの識別子までの URL、例: <公開の配信 API のオリジン>/demo) */
14
+ /** 公開の API の中継先(base は公開の API の基点、例: https://<プロジェクトの ID>--api.tunasand.app/v1) */
15
15
  export type Upstream = Readonly<{
16
- origin: string;
16
+ base: string;
17
17
  apiKey: string;
18
- previewSecret?: string;
18
+ readToken?: string;
19
19
  }>;
20
20
  /** 公開の配信 API への中継(port Delivery、読み取りだけで書き込みの操作は405) */
21
- export declare function relayDelivery({ origin, apiKey, previewSecret }: Upstream): Delivery;
22
- /** 手元の配信 API のサーバー(/content/v1/… だけ、失敗は502、戻り値は origin と停止の関数) */
21
+ export declare function relayDelivery({ base, apiKey, readToken }: Upstream): Delivery;
22
+ /** 手元の配信 API のサーバー(失敗は502、戻り値は公開の API の基点として使う origin と停止の関数) */
23
23
  export declare function serveDelivery(delivery: Delivery, options?: Readonly<{
24
24
  port?: number;
25
25
  hostname?: string;
@@ -27,3 +27,4 @@ export declare function serveDelivery(delivery: Delivery, options?: Readonly<{
27
27
  origin: string;
28
28
  close: () => Promise<void>;
29
29
  }>>;
30
+ export { fixtureOperations, type OperationFixture, operationFixtureName, operationFixtures } from './dev-operations.js';