@tunasand/sdk 0.11.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 (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +6 -4
  3. package/dist/analytics.js +113 -50
  4. package/dist/app.js +98 -9
  5. package/dist/{apps-DIxAWBSZ.js → apps-BysPfMuR.js} +102 -12
  6. package/dist/{bridge-Dv4NxGZ7.js → bridge-C2Bl-OAF.js} +1 -2
  7. package/dist/bridge.js +1 -1
  8. package/dist/cli.js +2 -2
  9. package/dist/{collection-nUz1RetA.js → collection-26aglrg6.js} +20 -2
  10. package/dist/delivery.js +1 -1
  11. package/dist/{embeds-B-Dbn64k.js → embeds-DY6O5TrJ.js} +2 -2
  12. package/dist/end-users.js +29 -25
  13. package/dist/{errorLabels-aT2bnMsO.js → errorLabels-BK1NJ6Wz.js} +21 -5
  14. package/dist/i18n.js +2 -2
  15. package/dist/integrations.js +2 -2
  16. package/dist/{ja-CrY_72Tn.js → ja-B3lAaOhZ.js} +13 -11
  17. package/dist/{workflow-CUpl6hO_.js → paymentPort-p1jV44Zz.js} +57 -2
  18. package/dist/{schema-Dcg1ajnW.js → schema-Bs_BUUNv.js} +35 -7
  19. package/dist/schema.js +4 -4
  20. package/dist/types/access/src/handoff.d.ts +1 -1
  21. package/dist/types/access/src/oidc.d.ts +2 -0
  22. package/dist/types/contract/src/api/define.d.ts +165 -0
  23. package/dist/types/contract/src/app.d.ts +22 -7
  24. package/dist/types/contract/src/appChannels.d.ts +65 -27
  25. package/dist/types/contract/src/appDependencies.d.ts +22 -2
  26. package/dist/types/contract/src/appInbound.d.ts +26 -1
  27. package/dist/types/contract/src/appSecrets.d.ts +18 -0
  28. package/dist/types/contract/src/appServer.d.ts +57 -7
  29. package/dist/types/contract/src/apps.d.ts +15 -6
  30. package/dist/types/contract/src/auditActions.d.ts +2 -2
  31. package/dist/types/contract/src/auditLabels.d.ts +10 -1
  32. package/dist/types/contract/src/authorize.d.ts +1 -1
  33. package/dist/types/contract/src/bridge.d.ts +1 -1
  34. package/dist/types/contract/src/consents.d.ts +1 -6
  35. package/dist/types/contract/src/embeds.d.ts +11 -9
  36. package/dist/types/contract/src/endUsers.d.ts +3 -0
  37. package/dist/types/contract/src/errorLabels.d.ts +4 -1
  38. package/dist/types/contract/src/errorLabelsEn.d.ts +4 -1
  39. package/dist/types/contract/src/errors.d.ts +2 -2
  40. package/dist/types/contract/src/eventTraces.d.ts +0 -2
  41. package/dist/types/contract/src/hostingRpc.d.ts +21 -2
  42. package/dist/types/contract/src/import.d.ts +3 -3
  43. package/dist/types/contract/src/index.d.ts +16 -13
  44. package/dist/types/contract/src/issueLabels.d.ts +11 -3
  45. package/dist/types/contract/src/issueLabelsEn.d.ts +4 -0
  46. package/dist/types/contract/src/manage.d.ts +5 -0
  47. package/dist/types/contract/src/notices.d.ts +2 -3
  48. package/dist/types/contract/src/operationEffects.d.ts +39 -0
  49. package/dist/types/contract/src/operatorOperations.d.ts +104 -47
  50. package/dist/types/contract/src/paymentPort.d.ts +129 -0
  51. package/dist/types/contract/src/readPages.d.ts +92 -0
  52. package/dist/types/contract/src/roles.d.ts +2 -2
  53. package/dist/types/contract/src/settingProblems.d.ts +18 -1
  54. package/dist/types/contract/src/workflow.d.ts +5 -2
  55. package/dist/types/contract/src/workspaceItems.d.ts +3 -1
  56. package/dist/types/contract/src/workspacePaths.d.ts +1 -1
  57. package/dist/types/schema/src/collection.d.ts +4 -0
  58. package/dist/types/schema/src/file.d.ts +2 -0
  59. package/dist/types/schema/src/index.d.ts +3 -2
  60. package/dist/types/schema/src/indexes.d.ts +11 -0
  61. package/dist/types/schema/src/labels/en.d.ts +2 -0
  62. package/dist/types/schema/src/labels/ja.d.ts +13 -11
  63. package/dist/types/schema/src/problems.d.ts +13 -11
  64. package/dist/types/sdk/src/app.d.ts +11 -8
  65. package/dist/types/sdk/src/end-users.d.ts +12 -15
  66. package/dist/types/sdk/src/schema.d.ts +1 -1
  67. package/dist/{types-DkO2N7u2.js → types-CYnY-63C.js} +1 -1
  68. package/dist/types.js +1 -1
  69. package/dist/{typesSource-VJIxtN9b.js → typesSource-BTA9-rcB.js} +1 -1
  70. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.12.0
4
+
5
+ 公開のAPI(`/v1`)の形をHTTP APIの規約(#898)に揃えた。互換は持たない。
6
+
7
+ - 互換のない変更: 本人のレコード`createSelfClient`は、一覧を`GET <基点>/end-users/me/<コレクション>`、更新を`PATCH`、削除を`DELETE`で呼ぶ。本人のIDは本文の`end_user_id`でなく、ヘッダー`tunasand-end-user`で送る
8
+ - 互換のない変更: `createSelfClient`の`create`と`update`は、`{ id, created }`と`{ version }`でなく、本人が見られる項目のレコード`SelfItem`を返す。`delete`は`{ deleted: true }`でなく、`_meta.deleted_at`つきのレコードを返す。`update`の`values`はJSON Merge Patchとして重ね、`null`は値を空にする
9
+ - 変更: `createEndUsersClient`の`ensure`の戻り値は変わらない(公開のAPIの応答はエンドユーザーの資源になり、`created`はSDKが状態のコード201から決める)
10
+ - 公開のAPIの経路の変更(SDKの関数のない経路): 同意の一覧は`GET /end-users/consents?end_user_id=`の`{ data, next_cursor }`、チャネルのブロックは`GET /end-users/channel-blocks?end_user_id=`、販売中のオファーは`GET /end-users/offers`の`{ data, next_cursor }`になった。`POST /end-users/consents:query`と`/end-users/offers:query`は使えない。人の作成`POST /end-users`と`:ensure`はエンドユーザー`{ id, status }`を、同意の記録`POST /end-users/consents`は同意の記録を、抑止の記録`POST /end-users/suppressions`は201と`{ channel, purpose }`を、`consents:set-block`は`{ channel, blocked }`を返す
11
+ - 公開のAPIの経路の変更: アプリのデータのAPIの一覧`GET /app/collections/<名前>/records`は、配信のAPIと同じ`filter[key]`、`filter[key][in]`、`order`を受ける。集計の時刻の範囲は`filter[<時刻のフィールド>][gte]`と`[lte]`で指定する。`records:query`と`records:find`は使えない。作成は作ったレコードを、更新は200と更新後のレコードを、ゴミ箱のあるコレクションの削除は`_meta.deleted_at`つきのレコードを返す
12
+ - 互換のない変更: アプリの経路`AppRoute`は`policy`の代わりに`credentials`(`PERSON`か`DELEGABLE`)、`summary`、`response`を持ち、一覧の経路は`list`(`appRecordList`か`boundedList`)を持つ。`AppRoutePolicy`をなくし、`AppRouteCredentials`を足した。公開のAPIの経路`AppDeliveryRoute`も`summary`、`response`、`list`を持つ
13
+ - 互換のない変更: トークンの交換の経路は`/v1/embeds/token`(`TOKEN_EXCHANGE.path`)になった。`exchangeDelegation`と`exchangeSessionToken`の`base`は環境のCMSのURLのまま
14
+ - 互換のない変更: 保存前の検査`SaveCheck`の`collection`は、マニフェストのコレクションの名前(環境のコレクションのIDではない)
15
+ - 変更: `@tunasand/sdk/schema`に`isIndexableField`(索引を宣言できる項目か)を足した
16
+ - 変更: 状態の口に`getMany`(複数のキーの値を1回で読む)を、チャネルの口に`configuredOf`(結んだすべてのチャネルの秘密値の有無)と`inboundUrlsOf`(結んだすべてのチャネルの受信のURL)を足した
17
+ - 変更: `ADMIN_AREA_OPERATION`の値を、管理の領域だけを表す専用のID(`area.admin`)にした。`user.can[ADMIN_AREA_OPERATION]`の使い方は変わらない
18
+
3
19
  ## 0.11.0
4
20
 
5
21
  公開のAPIをプロジェクトのホストの`/v1`に移した(#823)。互換は持たない。
package/README.md CHANGED
@@ -334,7 +334,9 @@ const shown = visibleItem(lesson, access, entitledKeysOf(lessonType));
334
334
  | `link({ idToken, inviteCode })` | `POST <基点>/end-users:link` | `{ id_token, invite_code }` |
335
335
  | `ensure({ issuer, audience, subject })` | `POST <基点>/end-users:ensure` | `{ issuer, audience, subject }` |
336
336
  | `checkSubmission(collection, idToken, version)` | `POST <基点>/forms/<コレクション>/submissions:check?version=` | `{ id_token }` |
337
- | (なし) | `POST <基点>/end-users`・`/end-users/consents`・`/end-users/consents:query`・`/end-users/consents:check`・`/end-users/consents:set-block`・`/end-users/suppressions` | `end_user_id`ほか |
337
+ | (なし) | `POST <基点>/end-users` | `{ key? }` |
338
+ | (なし、インストールのトークンだけ) | `POST <基点>/end-users/consents`・`/end-users/consents:check`・`/end-users/consents:set-block`・`/end-users/suppressions`・`/end-users/payments:checkout`・`/end-users/payments:portal` | `end_user_id`ほか |
339
+ | (なし、インストールのトークンだけ) | `GET <基点>/end-users/consents`・`/end-users/channel-blocks`(クエリ`end_user_id`)・`/end-users/offers` | なし(応答は`{ data, next_cursor }`) |
338
340
 
339
341
  - 応答: エンドユーザーのID、状態(`active`・`suspended`)と状態の版`version`、権利のすべて(`entitlements`の対象のコレクション`collection`とレコード`record`(どちらも`{ id, slug }`)・`starts_on`・`ends_on`、失効の時刻`expires_at`、エンドユーザーの状態だけ)、判定の基準の日付`today`、障害の間の猶予`grace_sec`
340
342
  - 業務の失敗(`END_USER_API_ERRORS`)は線の上のコードのまま`{ ok: false, error, params?, requestId? }`で返り、ほかは`DeliveryError`。鍵の権限が足りなければ403の`forbidden`(`params.required.operation`)
@@ -360,10 +362,10 @@ if (page.ok && page.value.data[0]) await own.update('progress', page.value.data[
360
362
  ```
361
363
 
362
364
  - コレクションの宣言`selfOps`(`read_self`・`create_self`・`update_self`・`delete_self`)と、インストールのコレクションを名指しした能力が要る。書けるのは本人が書ける印`selfWritable`の項目だけで、本人のエンドユーザーへの参照のフィールドはTunasandが入れる
363
- - 同じ組(本人を含む一意の組)の`create`は作らずに前の行を`created: false`で返す。`update`は一覧の`_meta.version`を渡し、古ければ`version_conflict`
365
+ - `create`と`update`は本人が見られる項目のレコードを返す。同じ組(本人を含む一意の組)の`create`は作らずに前の行を返す。`update`の値はJSON Merge Patchとして重ね(`null`は値を空にする)、一覧の`_meta.version`を渡し、古ければ`version_conflict`
364
366
  - 一覧の`query`は配信APIの一覧の文法で、絞れるのは本人が見られる項目だけ。応答はキャッシュされない
365
- - 削除は`delete(collection, id, endUserId)`(0.2.0から。前の`remove`)
366
- - 経路(0.3.0から): 一覧は`<コレクション>:query`、作成は`<コレクション>`、更新は`<コレクション>/<id>:update`、削除は`<コレクション>/<id>:delete`(エンドユーザーのAPIと同じ`:動詞`の形)。本文の本人のIDは`end_user_id`
367
+ - 削除は`delete(collection, id, endUserId)`で、`_meta.deleted_at`つきのレコードを返す
368
+ - 経路(0.12.0から): 一覧は`GET <コレクション>`、作成は`POST <コレクション>`、更新は`PATCH <コレクション>/<id>`、削除は`DELETE <コレクション>/<id>`。本人のIDはヘッダー`tunasand-end-user`で送る(パスとクエリはアクセスのログに残るため)
367
369
  - 業務の失敗は線の上のコードのまま値で返る(`not_found`・`forbidden`・`invalid_input`・`save_unmet`・`version_conflict`・`invalid_state`・`rate_limited`)。`forbidden`はコレクションを名指しした能力が足りないときで、`params.required.operation`に足りない操作。`invalid_state`の`params.reason`は`end_user_inactive`(本人が停止)か`self_limit`。`rate_limited`は人ごとの書き込みか、インストールごとの要求の回数の上限
368
370
 
369
371
  ## プレビュー
package/dist/analytics.js CHANGED
@@ -1,10 +1,10 @@
1
- import "./errorLabels-aT2bnMsO.js";
2
- import { l as ACTOR_KINDS } from "./apps-DIxAWBSZ.js";
3
- import "./embeds-B-Dbn64k.js";
4
- import "./bridge-Dv4NxGZ7.js";
1
+ import "./errorLabels-BK1NJ6Wz.js";
2
+ import { f as ACTOR_KINDS } from "./apps-BysPfMuR.js";
3
+ import "./embeds-DY6O5TrJ.js";
4
+ import "./bridge-C2Bl-OAF.js";
5
5
  import { a as END_USER_STATUSES, i as END_USER_EVENTS } from "./endUsers-DODfjnv1.js";
6
- import { o as IMPORT_EVENTS } from "./workflow-CUpl6hO_.js";
7
- import { c as schemaProblemText } from "./schema-Dcg1ajnW.js";
6
+ import { m as IMPORT_EVENTS } from "./paymentPort-p1jV44Zz.js";
7
+ import { l as schemaProblemText } from "./schema-Bs_BUUNv.js";
8
8
  import { z } from "zod";
9
9
  import { defineEventSchema, isBotUserAgent } from "@ryusenkei/web/analytics";
10
10
  // ../contract/src/webhooks.ts
@@ -29,48 +29,60 @@ const FORM_EVENTS = { submitted: "form.submitted" };
29
29
  // ../contract/src/hostingRpc.ts
30
30
  const SITE_REF = ["projectId", "assignmentId"];
31
31
  /**
32
- * 運営者の操作ごとの RPC のメソッドと、入力の欄(どれも空でない文字列)
33
- * method が null の操作はコアのドメインが受ける(tunasand-hosting へは syncHostnames でコピーする)
32
+ * 運営者の操作ごとの RPC のメソッド、経路の操作の名前(verb)、入力の欄(どれも空でない文字列)
33
+ * - 経路: サイトの操作は運営者の API の `/projects/{projectId}/sites/{assignmentId}:<verb>`
34
+ * 知らせの確認は `/hosting/alerts/{id}:<verb>`。残りの欄は本文
35
+ * - method が null の操作はコアのドメインが受ける(tunasand-hosting へは syncHostnames でコピーする)
34
36
  */
35
37
  const HOSTING_OPERATIONS = {
36
38
  stop: {
37
39
  method: "stopSite",
40
+ verb: "stop",
38
41
  fields: [...SITE_REF, "reason"]
39
42
  },
40
43
  resume: {
41
44
  method: "resumeSite",
45
+ verb: "resume",
42
46
  fields: SITE_REF
43
47
  },
44
48
  reattach: {
45
49
  method: "reattachResources",
50
+ verb: "reattach",
46
51
  fields: SITE_REF
47
52
  },
48
53
  purge: {
49
54
  method: "purgeSiteResources",
55
+ verb: "purge",
50
56
  fields: SITE_REF
51
57
  },
52
58
  hostname_request: {
53
59
  method: null,
60
+ verb: "request-hostname",
54
61
  fields: [...SITE_REF, "hostname"]
55
62
  },
56
63
  hostname_verify: {
57
64
  method: null,
65
+ verb: "verify-hostname",
58
66
  fields: [...SITE_REF, "hostname"]
59
67
  },
60
68
  hostname_status: {
61
69
  method: null,
70
+ verb: "check-hostname",
62
71
  fields: [...SITE_REF, "hostname"]
63
72
  },
64
73
  hostname_remove: {
65
74
  method: null,
75
+ verb: "remove-hostname",
66
76
  fields: [...SITE_REF, "hostname"]
67
77
  },
68
78
  trial_hostname: {
69
79
  method: null,
80
+ verb: "set-trial-hostname",
70
81
  fields: [...SITE_REF, "name"]
71
82
  },
72
83
  ack: {
73
84
  method: "acknowledgeAlert",
85
+ verb: "acknowledge",
74
86
  fields: ["id"]
75
87
  }
76
88
  };
@@ -108,21 +120,39 @@ const OPERATOR_OPERATIONS = [
108
120
  available: true
109
121
  },
110
122
  {
111
- id: "secrets",
112
- cli: "secrets",
123
+ id: "migrate",
124
+ cli: "migrate",
125
+ method: "POST",
126
+ path: "/registry:migrate",
127
+ level: "reversible",
128
+ place: { screen: "maintenance" },
129
+ available: true
130
+ },
131
+ {
132
+ id: "one-time-targets",
113
133
  method: "GET",
114
- path: "/secrets",
134
+ path: "/one-time",
115
135
  level: "read",
116
136
  place: { screen: "maintenance" },
117
137
  available: true
118
138
  },
119
139
  {
120
- id: "migrate",
121
- cli: "migrate",
140
+ id: "one-time",
122
141
  method: "POST",
123
- path: "/migrate",
142
+ path: "/projects/{project}:run-one-time",
124
143
  level: "reversible",
125
- place: { screen: "maintenance" },
144
+ place: tab("environments"),
145
+ environment: true,
146
+ available: true
147
+ },
148
+ {
149
+ id: "secrets",
150
+ cli: "secrets",
151
+ method: "GET",
152
+ path: "/projects/{project}/secrets",
153
+ level: "read",
154
+ place: tab("environments"),
155
+ environment: true,
126
156
  available: true
127
157
  },
128
158
  {
@@ -138,7 +168,7 @@ const OPERATOR_OPERATIONS = [
138
168
  id: "paused",
139
169
  cli: "paused",
140
170
  method: "GET",
141
- path: "/paused",
171
+ path: "/registry",
142
172
  level: "read",
143
173
  place: { screen: "maintenance" },
144
174
  available: true
@@ -147,7 +177,7 @@ const OPERATOR_OPERATIONS = [
147
177
  id: "pause",
148
178
  cli: "pause",
149
179
  method: "POST",
150
- path: "/pause",
180
+ path: "/registry:pause",
151
181
  level: "heavy",
152
182
  place: { screen: "maintenance" },
153
183
  available: true
@@ -156,7 +186,7 @@ const OPERATOR_OPERATIONS = [
156
186
  id: "resume",
157
187
  cli: "resume",
158
188
  method: "POST",
159
- path: "/resume",
189
+ path: "/registry:resume",
160
190
  level: "reversible",
161
191
  place: { screen: "maintenance" },
162
192
  available: true
@@ -170,6 +200,23 @@ const OPERATOR_OPERATIONS = [
170
200
  place: { screen: "projects" },
171
201
  available: true
172
202
  },
203
+ {
204
+ id: "organizations",
205
+ cli: "organizations",
206
+ method: "GET",
207
+ path: "/organizations",
208
+ level: "read",
209
+ place: { screen: "organizations" },
210
+ available: true
211
+ },
212
+ {
213
+ id: "organization-sync",
214
+ method: "POST",
215
+ path: "/organizations:sync",
216
+ level: "read",
217
+ place: { screen: "organizations" },
218
+ available: true
219
+ },
173
220
  {
174
221
  id: "create",
175
222
  cli: "create",
@@ -182,8 +229,6 @@ const OPERATOR_OPERATIONS = [
182
229
  {
183
230
  id: "hosting",
184
231
  cli: "hosting",
185
- method: "POST",
186
- path: "/hosting",
187
232
  level: "heavy",
188
233
  place: { screen: "hosting" },
189
234
  available: true
@@ -206,6 +251,14 @@ const OPERATOR_OPERATIONS = [
206
251
  place: { screen: "apps" },
207
252
  available: true
208
253
  },
254
+ {
255
+ id: "standard-app-candidates",
256
+ method: "GET",
257
+ path: "/standard-app-candidates",
258
+ level: "read",
259
+ place: { screen: "apps" },
260
+ available: true
261
+ },
209
262
  {
210
263
  id: "standard-app-set",
211
264
  cli: "standard-app-set",
@@ -218,8 +271,8 @@ const OPERATOR_OPERATIONS = [
218
271
  {
219
272
  id: "standard-app-remove",
220
273
  cli: "standard-app-remove",
221
- method: "POST",
222
- path: "/standard-apps/{app}/remove",
274
+ method: "DELETE",
275
+ path: "/standard-apps/{app}",
223
276
  level: "heavy",
224
277
  place: { screen: "apps" },
225
278
  available: true
@@ -255,7 +308,7 @@ const OPERATOR_OPERATIONS = [
255
308
  id: "app-keys",
256
309
  cli: "app-keys",
257
310
  method: "POST",
258
- path: "/apps/{app}/keys",
311
+ path: "/apps/{app}:set-keys",
259
312
  level: "heavy",
260
313
  place: { screen: "apps" },
261
314
  available: true
@@ -273,7 +326,7 @@ const OPERATOR_OPERATIONS = [
273
326
  id: "registry-backup",
274
327
  cli: "backup",
275
328
  method: "POST",
276
- path: "/backups/registry",
329
+ path: "/backups:registry",
277
330
  level: "reversible",
278
331
  place: { screen: "maintenance" },
279
332
  available: true
@@ -282,7 +335,7 @@ const OPERATOR_OPERATIONS = [
282
335
  id: "registry-download",
283
336
  cli: "backup:download",
284
337
  method: "GET",
285
- path: "/backups/download?registry",
338
+ path: "/backups/{backup}:download?registry",
286
339
  level: "read",
287
340
  place: { screen: "maintenance" },
288
341
  available: true
@@ -316,8 +369,8 @@ const OPERATOR_OPERATIONS = [
316
369
  {
317
370
  id: "delete-project",
318
371
  cli: "delete-project",
319
- method: "POST",
320
- path: "/projects/{project}/delete-project",
372
+ method: "DELETE",
373
+ path: "/projects/{project}",
321
374
  level: "irreversible",
322
375
  place: tab("overview"),
323
376
  available: true
@@ -325,8 +378,8 @@ const OPERATOR_OPERATIONS = [
325
378
  {
326
379
  id: "delete-trial",
327
380
  cli: "delete-trial",
328
- method: "POST",
329
- path: "/projects/{project}/delete-trial",
381
+ method: "DELETE",
382
+ path: "/projects/{project}",
330
383
  level: "irreversible",
331
384
  place: tab("overview"),
332
385
  when: "trial",
@@ -345,7 +398,7 @@ const OPERATOR_OPERATIONS = [
345
398
  id: "copy-env",
346
399
  cli: "copy-env",
347
400
  method: "POST",
348
- path: "/projects/{project}/copy-environment",
401
+ path: "/projects/{project}/environments:copy",
349
402
  level: "heavy",
350
403
  place: tab("environments"),
351
404
  available: true
@@ -353,8 +406,8 @@ const OPERATOR_OPERATIONS = [
353
406
  {
354
407
  id: "delete-env",
355
408
  cli: "delete-env",
356
- method: "POST",
357
- path: "/projects/{project}/delete-environment",
409
+ method: "DELETE",
410
+ path: "/projects/{project}/environments/{environment}",
358
411
  level: "irreversible",
359
412
  place: tab("environments"),
360
413
  when: "notLive",
@@ -364,7 +417,7 @@ const OPERATOR_OPERATIONS = [
364
417
  id: "freeze",
365
418
  cli: "freeze",
366
419
  method: "POST",
367
- path: "/projects/{project}/freeze",
420
+ path: "/projects/{project}:freeze",
368
421
  level: "heavy",
369
422
  place: tab("environments"),
370
423
  available: true
@@ -373,7 +426,7 @@ const OPERATOR_OPERATIONS = [
373
426
  id: "unfreeze",
374
427
  cli: "unfreeze",
375
428
  method: "POST",
376
- path: "/projects/{project}/unfreeze",
429
+ path: "/projects/{project}:unfreeze",
377
430
  level: "reversible",
378
431
  place: tab("environments"),
379
432
  available: true
@@ -382,7 +435,7 @@ const OPERATOR_OPERATIONS = [
382
435
  id: "promote-plan",
383
436
  cli: "promote-plan",
384
437
  method: "POST",
385
- path: "/projects/{project}/promote-plan",
438
+ path: "/projects/{project}:plan-promotion",
386
439
  level: "read",
387
440
  place: tab("environments"),
388
441
  when: "notLive",
@@ -392,7 +445,7 @@ const OPERATOR_OPERATIONS = [
392
445
  id: "promote-commit",
393
446
  cli: "promote-commit",
394
447
  method: "POST",
395
- path: "/projects/{project}/promote-commit",
448
+ path: "/projects/{project}:promote",
396
449
  level: "heavy",
397
450
  place: tab("environments"),
398
451
  when: "notLive",
@@ -402,7 +455,7 @@ const OPERATOR_OPERATIONS = [
402
455
  id: "prune",
403
456
  cli: "prune",
404
457
  method: "POST",
405
- path: "/projects/{project}/prune",
458
+ path: "/projects/{project}:prune",
406
459
  level: "irreversible",
407
460
  place: tab("environments"),
408
461
  environment: true,
@@ -423,7 +476,7 @@ const OPERATOR_OPERATIONS = [
423
476
  id: "download",
424
477
  cli: "backup:download",
425
478
  method: "GET",
426
- path: "/backups/download?project={project}",
479
+ path: "/backups/{backup}:download?project={project}",
427
480
  level: "read",
428
481
  place: tab("backups"),
429
482
  environment: true,
@@ -433,7 +486,7 @@ const OPERATOR_OPERATIONS = [
433
486
  id: "backup",
434
487
  cli: "backup",
435
488
  method: "POST",
436
- path: "/projects/{project}/backup",
489
+ path: "/projects/{project}:backup",
437
490
  level: "reversible",
438
491
  place: tab("backups"),
439
492
  environment: true,
@@ -443,7 +496,7 @@ const OPERATOR_OPERATIONS = [
443
496
  id: "restore",
444
497
  cli: "restore",
445
498
  method: "POST",
446
- path: "/projects/{project}/restore",
499
+ path: "/projects/{project}:restore",
447
500
  level: "irreversible",
448
501
  place: tab("backups"),
449
502
  environment: true,
@@ -454,7 +507,7 @@ const OPERATOR_OPERATIONS = [
454
507
  id: "import",
455
508
  cli: "import",
456
509
  method: "POST",
457
- path: "/projects/{project}/import",
510
+ path: "/projects/{project}:import",
458
511
  level: "irreversible",
459
512
  place: tab("backups"),
460
513
  environment: true,
@@ -465,7 +518,7 @@ const OPERATOR_OPERATIONS = [
465
518
  id: "switch-host",
466
519
  cli: "switch-host",
467
520
  method: "POST",
468
- path: "/projects/{project}/hosts",
521
+ path: "/projects/{project}/hosts:switch",
469
522
  level: "heavy",
470
523
  place: tab("hosts"),
471
524
  available: true
@@ -474,7 +527,7 @@ const OPERATOR_OPERATIONS = [
474
527
  id: "set-host",
475
528
  cli: "set-host",
476
529
  method: "POST",
477
- path: "/projects/{project}/hosts",
530
+ path: "/projects/{project}/hosts:replace",
478
531
  level: "heavy",
479
532
  place: tab("hosts"),
480
533
  available: true
@@ -483,7 +536,7 @@ const OPERATOR_OPERATIONS = [
483
536
  id: "remove-alias",
484
537
  cli: "remove-alias",
485
538
  method: "POST",
486
- path: "/projects/{project}/hosts",
539
+ path: "/projects/{project}/hosts:remove-alias",
487
540
  level: "heavy",
488
541
  place: tab("hosts"),
489
542
  available: true
@@ -492,7 +545,7 @@ const OPERATOR_OPERATIONS = [
492
545
  id: "emergency",
493
546
  cli: "emergency",
494
547
  method: "POST",
495
- path: "/projects/{project}/emergency",
548
+ path: "/projects/{project}:emergency",
496
549
  level: "heavy",
497
550
  place: tab("access"),
498
551
  available: true
@@ -501,7 +554,7 @@ const OPERATOR_OPERATIONS = [
501
554
  id: "revoke-grants",
502
555
  cli: "revoke-grants",
503
556
  method: "POST",
504
- path: "/projects/{project}/revoke-grants",
557
+ path: "/projects/{project}:revoke-grants",
505
558
  level: "reversible",
506
559
  place: tab("access"),
507
560
  environment: true,
@@ -511,17 +564,26 @@ const OPERATOR_OPERATIONS = [
511
564
  id: "api-key-create",
512
565
  cli: "api-key-create",
513
566
  method: "POST",
514
- path: "/projects/{project}/api-key-create",
567
+ path: "/projects/{project}/api-keys",
515
568
  level: "heavy",
516
569
  secret: true,
517
570
  place: tab("access"),
518
571
  available: true
519
572
  },
573
+ {
574
+ id: "channel-key",
575
+ cli: "channel-key",
576
+ method: "POST",
577
+ path: "/projects/{project}:issue-channel-key",
578
+ level: "heavy",
579
+ place: tab("access"),
580
+ available: true
581
+ },
520
582
  {
521
583
  id: "test-integration",
522
584
  cli: "test-integration",
523
585
  method: "POST",
524
- path: "/projects/{project}/integrations/{registration}/test",
586
+ path: "/projects/{project}/integrations/{registration}:test",
525
587
  level: "reversible",
526
588
  place: tab("access"),
527
589
  available: true
@@ -530,7 +592,7 @@ const OPERATOR_OPERATIONS = [
530
592
  id: "trial-session",
531
593
  cli: "trial-session",
532
594
  method: "POST",
533
- path: "/projects/{project}/trial-session",
595
+ path: "/projects/{project}:start-trial-session",
534
596
  level: "reversible",
535
597
  secret: true,
536
598
  place: tab("trial"),
@@ -601,8 +663,9 @@ const OPERATOR_OPERATIONS = [
601
663
  ];
602
664
  new Map(OPERATOR_OPERATIONS.map((o) => [o.id, o]));
603
665
  const patternOf = (path) => new RegExp(`^${path.split("?")[0].replace(/\{\w+\}/g, "[^/]+")}$`);
604
- OPERATOR_OPERATIONS.flatMap((o) => "path" in o && o.method === "POST" ? [{
666
+ OPERATOR_OPERATIONS.flatMap((o) => "path" in o && o.method !== "GET" ? [{
605
667
  op: o,
668
+ method: o.method,
606
669
  pattern: patternOf(o.path)
607
670
  }] : []);
608
671
  // ../contract/src/day.ts
package/dist/app.js CHANGED
@@ -1,13 +1,14 @@
1
- import { _ as JSON_BODY_MAX, a as problemBodyWithoutType, f as problemEnglish, g as apiIssueText, o as problemResponse, r as errorText } from "./errorLabels-aT2bnMsO.js";
1
+ import { _ as JSON_BODY_MAX, a as problemBodyWithoutType, f as problemEnglish, g as apiIssueText, o as problemResponse, r as errorText } from "./errorLabels-BK1NJ6Wz.js";
2
2
  import { i as newUuidV7 } from "./ids-DmtIoqBX.js";
3
3
  import { c as formatMessage, d as problemOf, f as problemText } from "./ja-axQPxMJ-.js";
4
- import { a as APP_CHANNEL_LIMITS, c as ADMIN_AREA_OPERATION, d as BUNDLED_APP_IDS, f as MESSAGE_LIMITS, h as MESSAGE_SKIP_REASONS, i as APP_CHANNEL_KIND_LIMITS, m as MESSAGE_RECEIVED, o as CHANNEL_ADDRESS_KINDS, p as MESSAGE_PORT, r as appToolPrefixOf, s as CHANNEL_CAPABILITIES, u as INSTALLATION_TOKEN } from "./apps-DIxAWBSZ.js";
5
- import { r as TOKEN_EXCHANGE } from "./embeds-B-Dbn64k.js";
6
- import { a as END_USER_REF, c as ORIGIN_REF, d as importItemOfRow, i as manifestDocumentOf, l as cyclicCollections, n as recordStateOf, r as NOTICES_PORT, s as IMPORT_ITEMS_MAX, t as isLiveState, u as importIdOf } from "./workflow-CUpl6hO_.js";
4
+ import { _ as MESSAGE_RECEIVED, a as APP_CHANNEL_LIMITS, c as CHANNEL_MODES, d as ADMIN_AREA_OPERATION, g as MESSAGE_PORT, h as MESSAGE_LIMITS, i as APP_CHANNEL_KIND_LIMITS, l as channelSettingPattern, m as BUNDLED_APP_IDS, o as CHANNEL_ADDRESS_KINDS, p as INSTALLATION_TOKEN, r as appToolPrefixOf, s as CHANNEL_CAPABILITIES, u as COLLECTION_SIZE_LIMITS, v as MESSAGE_SKIP_REASONS } from "./apps-BysPfMuR.js";
5
+ import { r as TOKEN_EXCHANGE } from "./embeds-DY6O5TrJ.js";
6
+ import { _ as cyclicCollections, a as PRICE_KINDS, c as priceLookupKeyOf, d as NOTICES_PORT, f as manifestDocumentOf, g as ORIGIN_REF, h as IMPORT_ITEMS_MAX, i as PRICE_INTERVALS, l as isLiveState, n as PAYMENT_PORT, o as PURCHASE_STATUSES, p as END_USER_REF, r as PRICE_CURRENCIES, s as SUBSCRIPTION_STATUSES, t as PAYMENT_LIMITS, u as recordStateOf, v as importIdOf, y as importItemOfRow } from "./paymentPort-p1jV44Zz.js";
7
7
  import { a as END_USER_STATUSES, t as END_USERS_KEY_TARGET } from "./endUsers-DODfjnv1.js";
8
8
  import { l as richTextProblemText, s as embedOfUrl } from "./declared-CE4a61qb.js";
9
9
  import { a as mergeStyle, c as ALIGNS, n as isSafeCssValue, o as sortMarks, r as HTML_TAG_MARKS, s as isSafeHref, u as isTableCell } from "./profile-DBsXLvvI.js";
10
- import { T as isPublishable, t as AUDIENCES } from "./collection-nUz1RetA.js";
10
+ import { E as isPublishable, t as AUDIENCES } from "./collection-26aglrg6.js";
11
+ import { z } from "zod";
11
12
  import { parseDocument } from "htmlparser2";
12
13
  // ../rich-text/src/normalize.ts
13
14
  const keyOf = (inline) => "component" in inline ? null : JSON.stringify([
@@ -786,6 +787,32 @@ const settingProblemText = (p, field) => problemText({
786
787
  field
787
788
  }
788
789
  });
790
+ /**
791
+ * 繰り返しフィールド(repeater)の値の検証(不正な値は例外)
792
+ * - 行番号 row は1から、sub はフィールドの表示名
793
+ * - 定義にないフィールドと、任意のフィールドの空文字は除外する
794
+ */
795
+ function settingRowsOf(key, value, fields) {
796
+ if (!Array.isArray(value)) throw new SettingProblem(key, "shape");
797
+ return value.map((input, i) => {
798
+ if (typeof input !== "object" || input === null || Array.isArray(input)) throw new SettingProblem(key, "shape");
799
+ const row = input;
800
+ const entries = fields.flatMap((f) => {
801
+ const v = row[f.key];
802
+ if (v !== void 0 && typeof v !== "string") throw new SettingProblem(key, "row_text", {
803
+ row: i + 1,
804
+ sub: f.label
805
+ });
806
+ const text = v?.trim() ?? "";
807
+ if (!text && f.required) throw new SettingProblem(key, "row_text", {
808
+ row: i + 1,
809
+ sub: f.label
810
+ });
811
+ return text ? [[f.key, text]] : [];
812
+ });
813
+ return Object.fromEntries(entries);
814
+ });
815
+ }
789
816
  // ../contract/src/workspaceItems.ts
790
817
  /** 日付のフィールドの予定が持つ source(`field:<コレクション>.<フィールド>`) */
791
818
  const calendarFieldSource = (f) => `field:${f.collection}.${f.field}`;
@@ -866,8 +893,8 @@ const APP_NOTICE_KINDS = ["record_received", "record_assigned"];
866
893
  /** アカウントへの知らせの上限(1回の宛先の数) */
867
894
  const APP_NOTIFY_LIMITS = { accountsMax: 50 };
868
895
  // ../contract/src/workspacePaths.ts
869
- /** ワークスペースのコレクションの経路(URL はレコードのスラッグ、record を省くと一覧) */
870
- const workspaceRecordPath = (collection, record) => `/collections/${encodeURIComponent(collection.slug)}/records${record === void 0 ? "" : `/${encodeURIComponent(String(record.slug))}`}`;
896
+ /** ワークスペースのコレクションの経路(コレクションはスラッグ、レコードは UUID、record を省くと一覧) */
897
+ const workspaceRecordPath = (collection, record) => `/collections/${encodeURIComponent(collection.slug)}/records${record === void 0 ? "" : `/${encodeURIComponent(String(record.id))}`}`;
871
898
  // src/delegation.ts
872
899
  /** アプリの JWT の有効の秒数(INSTALLATION_TOKEN.appJwtMaxSec の内) */
873
900
  const ASSERTION_TTL_SEC = 60;
@@ -933,7 +960,7 @@ async function exchanged(input, subject) {
933
960
  audience
934
961
  })
935
962
  });
936
- const res = await send(new Request(`${input.base}/api/embeds/token`, {
963
+ const res = await send(new Request(`${input.base}${TOKEN_EXCHANGE.path}`, {
937
964
  method: "POST",
938
965
  headers: { "content-type": "application/x-www-form-urlencoded" },
939
966
  body: body.toString()
@@ -960,6 +987,68 @@ const bearerClient = (input) => ({ fetch: (path, init = {}) => {
960
987
  });
961
988
  return input.fetch ? input.fetch(request) : fetch(request);
962
989
  } });
990
+ // ../contract/src/api/define.ts
991
+ /** ワークスペースの経路の資格の組(人のログイン、MCP、人の代理のアプリ) */
992
+ const PERSON = ["session", "mcp"];
993
+ const DELEGABLE = [
994
+ "session",
995
+ "mcp",
996
+ "account_token"
997
+ ];
998
+ /** 行の数に上限のある一覧の宣言(order は並べ替えのキー、先頭の - は降順の既定。size は上限の定数のキーで、1ページで上限までの全件を返す) */
999
+ const boundedList = (defaultOrder, size) => {
1000
+ const limit = COLLECTION_SIZE_LIMITS[size];
1001
+ return {
1002
+ keys: "fixed",
1003
+ indexes: [],
1004
+ bounded: {
1005
+ keys: [defaultOrder.replace(/^-/, "")],
1006
+ size
1007
+ },
1008
+ defaultOrder,
1009
+ filters: {},
1010
+ limit: {
1011
+ default: limit,
1012
+ max: limit
1013
+ }
1014
+ };
1015
+ };
1016
+ /**
1017
+ * アプリのコレクションをレコードの口のページ(作成の新しい順、続きは口のカーソル)で読むアプリの経路の一覧の宣言
1018
+ * - collection はマニフェストのコレクションの名前。索引の表は c_{<名前>}(インストールで決まるコレクションの表)
1019
+ * - filters はレコードの口の where に渡す絞り込み(索引の後の条件で、走査の上限で打ち切る)
1020
+ */
1021
+ const appRecordList = (collection, filters = {}) => ({
1022
+ keys: "fixed",
1023
+ indexes: [{
1024
+ name: `i_c_{${collection}}_created_at`,
1025
+ table: `c_{${collection}}`,
1026
+ order: "created_at",
1027
+ where: "deleted_at IS NULL"
1028
+ }],
1029
+ defaultOrder: "-created_at",
1030
+ filters
1031
+ });
1032
+ /** 一覧の応答(data はページの資源、next_cursor は続きがない場合だけ null) */
1033
+ const pageOf = (item) => z.object({
1034
+ data: z.array(item),
1035
+ next_cursor: z.string().nullable()
1036
+ });
1037
+ z.object({
1038
+ count: z.int().min(0).max(2 ** 31 - 1),
1039
+ capped: z.boolean()
1040
+ });
1041
+ /** 型を文書に書かないオブジェクト(中身はコンテンツスキーマとアプリの宣言が決める) */
1042
+ const OBJECT = z.record(z.string(), z.unknown());
1043
+ z.iso.datetime({ offset: true });
1044
+ z.int().min(0).max(2 ** 31 - 1);
1045
+ z.looseObject({
1046
+ id: z.string(),
1047
+ _meta: OBJECT.optional()
1048
+ }).meta({
1049
+ id: "Record",
1050
+ description: "record values; fields follow the content schema (docs/specs/values.md); _meta is left out when fields selects other fields"
1051
+ });
963
1052
  // src/app.ts
964
1053
  /** 相関の ID のヘッダー(CMS の応答とログと同じ名前) */
965
1054
  const REQUEST_ID_HEADER = "x-request-id";
@@ -1049,4 +1138,4 @@ async function appUser(ctx) {
1049
1138
  if (!res.ok) throw new Error(`app_user_unavailable: ${res.status}`);
1050
1139
  return await res.json();
1051
1140
  }
1052
- export { ADMIN_AREA_OPERATION, APP_CHANNEL_KIND_LIMITS, APP_CHANNEL_LIMITS, APP_FILE_LIMITS, APP_MAIL_SKIP_REASONS, APP_NOTICE_KINDS, APP_NOTIFY_LIMITS, APP_STATE_LIMITS, APP_USAGE_ERRORS, AUDIENCES, BUNDLED_APP_IDS, CHANNEL_ADDRESS_KINDS, CHANNEL_CAPABILITIES, END_USERS_KEY_TARGET, END_USER_REF, END_USER_STATUSES, IMPORT_ITEMS_MAX, JSON_BODY_MAX, MAIL_CAPABILITIES, MESSAGE_LIMITS, MESSAGE_PORT, MESSAGE_RECEIVED, MESSAGE_SKIP_REASONS, NOTICES_PORT, NO_SETTINGS, ORIGIN_REF, PORT_DONE, SettingProblem, aggregateJobIdOf, allRecordPages, appAssertion, appCollectionCan, appFailure, appFailureOf, appInvalid, appIssue, appJson, appPortResponse, appProblems, appToolPrefixOf, appUser, bearerClient, calendarFieldSource, cmsListAll, cyclicCollections, egressAllows, exchangeDelegation, exchangeSessionToken, importIdOf, importItemOfRow, isLiveState, isPublishable, manifestDocumentOf, newUuidV7, portValue, recordStateOf, richTextFromHtml, settingProblemText, workspaceRecordPath };
1141
+ export { ADMIN_AREA_OPERATION, APP_CHANNEL_KIND_LIMITS, APP_CHANNEL_LIMITS, APP_FILE_LIMITS, APP_MAIL_SKIP_REASONS, APP_NOTICE_KINDS, APP_NOTIFY_LIMITS, APP_STATE_LIMITS, APP_USAGE_ERRORS, AUDIENCES, BUNDLED_APP_IDS, CHANNEL_ADDRESS_KINDS, CHANNEL_CAPABILITIES, CHANNEL_MODES, DELEGABLE, END_USERS_KEY_TARGET, END_USER_REF, END_USER_STATUSES, IMPORT_ITEMS_MAX, JSON_BODY_MAX, MAIL_CAPABILITIES, MESSAGE_LIMITS, MESSAGE_PORT, MESSAGE_RECEIVED, MESSAGE_SKIP_REASONS, NOTICES_PORT, NO_SETTINGS, ORIGIN_REF, PAYMENT_LIMITS, PAYMENT_PORT, PERSON, PORT_DONE, PRICE_CURRENCIES, PRICE_INTERVALS, PRICE_KINDS, PURCHASE_STATUSES, SUBSCRIPTION_STATUSES, SettingProblem, aggregateJobIdOf, allRecordPages, appAssertion, appCollectionCan, appFailure, appFailureOf, appInvalid, appIssue, appJson, appPortResponse, appProblems, appRecordList, appToolPrefixOf, appUser, bearerClient, boundedList, calendarFieldSource, channelSettingPattern, cmsListAll, cyclicCollections, egressAllows, exchangeDelegation, exchangeSessionToken, importIdOf, importItemOfRow, isLiveState, isPublishable, manifestDocumentOf, newUuidV7, pageOf, portValue, priceLookupKeyOf, recordStateOf, richTextFromHtml, settingProblemText, settingRowsOf, workspaceRecordPath };