@tunasand/sdk 0.6.0 → 0.8.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 (186) hide show
  1. package/CHANGELOG.md +116 -84
  2. package/README.md +209 -195
  3. package/dist/analytics.js +638 -2
  4. package/dist/app.js +230 -24
  5. package/dist/apps-BxnJ1RlU.js +435 -0
  6. package/dist/{bridge-DYAYGV7t.js → bridge-DtHw9hS6.js} +3 -3
  7. package/dist/bridge.js +2 -2
  8. package/dist/cli.js +5 -4
  9. package/dist/{model-pmXzGX12.js → collection-BEOxeISR.js} +49 -12
  10. package/dist/{customers-C_vJY2_v.js → customers-DTbL0qn6.js} +5 -3
  11. package/dist/customers.js +2 -2
  12. package/dist/{declared-C_GvPiGF.js → declared-DuNMsdXw.js} +93 -5
  13. package/dist/delivery.js +39 -8
  14. package/dist/embeds-B5V54Zur.js +34 -0
  15. package/dist/{errorLabels-BcyRbv_i.js → errorLabels-BgtQ_zUn.js} +277 -264
  16. package/dist/i18n.js +4 -4
  17. package/dist/ids--RF7hGyC.js +36 -0
  18. package/dist/integrations.js +4 -29
  19. package/dist/{ja-C1HEWWTQ.js → ja-CeHU0EaY.js} +3 -3
  20. package/dist/{ja-C6lX0CeJ.js → ja-Du6ooL6i.js} +12 -11
  21. package/dist/{page-E_cYgZx-.js → page-Bzrj24sJ.js} +4 -4
  22. package/dist/{profile-D6t1QMQh.js → profile-1em_lcxq.js} +5 -5
  23. package/dist/rich-text.d.ts +1 -0
  24. package/dist/{body.js → rich-text.js} +6 -7
  25. package/dist/{schema-UQJWRyfJ.js → schema-WnobuwLg.js} +136 -97
  26. package/dist/schema.js +346 -1
  27. package/dist/types/access/src/handoff.d.ts +3 -3
  28. package/dist/types/access/src/jwt.d.ts +1 -1
  29. package/dist/types/access/src/oidc.d.ts +1 -1
  30. package/dist/types/{cms-contract → contract}/src/apiKeys.d.ts +1 -1
  31. package/dist/types/{cms-contract → contract}/src/app.d.ts +8 -15
  32. package/dist/types/contract/src/appDefinition.d.ts +127 -0
  33. package/dist/types/{cms-contract → contract}/src/appDependencies.d.ts +6 -13
  34. package/dist/types/contract/src/appServer.d.ts +136 -0
  35. package/dist/types/contract/src/approvalLabels.d.ts +26 -0
  36. package/dist/types/contract/src/approvals.d.ts +63 -0
  37. package/dist/types/{cms-contract → contract}/src/apps.d.ts +72 -29
  38. package/dist/types/contract/src/auditActions.d.ts +18 -0
  39. package/dist/types/contract/src/auditLabels.d.ts +127 -0
  40. package/dist/types/{cms-contract → contract}/src/authorize.d.ts +22 -63
  41. package/dist/types/{cms-contract → contract}/src/bridge.d.ts +6 -6
  42. package/dist/types/{cms-contract → contract}/src/customers.d.ts +6 -6
  43. package/dist/types/{cms-contract → contract}/src/embeds.d.ts +13 -7
  44. package/dist/types/{cms-contract → contract}/src/errorLabels.d.ts +18 -16
  45. package/dist/types/{cms-contract → contract}/src/errorLabelsEn.d.ts +9 -7
  46. package/dist/types/{cms-contract → contract}/src/errors.d.ts +11 -11
  47. package/dist/types/{cms-contract → contract}/src/failureStatus.d.ts +4 -3
  48. package/dist/types/contract/src/fieldAccess.d.ts +45 -0
  49. package/dist/types/contract/src/fieldRules.d.ts +41 -0
  50. package/dist/types/{cms-contract/src/assets.d.ts → contract/src/files.d.ts} +5 -5
  51. package/dist/types/{cms-contract → contract}/src/functions.d.ts +3 -3
  52. package/dist/types/contract/src/hostingRpc.d.ts +143 -0
  53. package/dist/types/contract/src/hostnames.d.ts +30 -0
  54. package/dist/types/{cms-contract → contract}/src/identifiers.d.ts +31 -28
  55. package/dist/types/contract/src/ids.d.ts +104 -0
  56. package/dist/types/{cms-contract → contract}/src/import.d.ts +3 -3
  57. package/dist/types/contract/src/importLabels.d.ts +3 -0
  58. package/dist/types/contract/src/index.d.ts +67 -0
  59. package/dist/types/{cms-contract → contract}/src/issueLabels.d.ts +27 -23
  60. package/dist/types/{cms-contract → contract}/src/issueLabelsEn.d.ts +15 -13
  61. package/dist/types/contract/src/labels.d.ts +11 -0
  62. package/dist/types/contract/src/legacyAuditLabels.d.ts +10 -0
  63. package/dist/types/contract/src/livePeriods.d.ts +18 -0
  64. package/dist/types/contract/src/manage.d.ts +47 -0
  65. package/dist/types/contract/src/manageLabels.d.ts +9 -0
  66. package/dist/types/contract/src/mcpAuth.d.ts +139 -0
  67. package/dist/types/contract/src/mcpLabels.d.ts +5 -0
  68. package/dist/types/{cms-contract → contract}/src/migration.d.ts +1 -1
  69. package/dist/types/contract/src/operatorOperations.d.ts +703 -0
  70. package/dist/types/contract/src/operators.d.ts +33 -0
  71. package/dist/types/{cms-contract → contract}/src/paths.d.ts +6 -8
  72. package/dist/types/contract/src/pending.d.ts +4 -0
  73. package/dist/types/{cms-contract → contract}/src/permissions.d.ts +2 -0
  74. package/dist/types/contract/src/principal.d.ts +110 -0
  75. package/dist/types/{cms-contract → contract}/src/problems.d.ts +4 -4
  76. package/dist/types/contract/src/projectRole.d.ts +6 -0
  77. package/dist/types/{cms-contract → contract}/src/roles.d.ts +4 -3
  78. package/dist/types/{cms-contract → contract}/src/settingProblems.d.ts +2 -2
  79. package/dist/types/{cms-contract → contract}/src/settings.d.ts +2 -2
  80. package/dist/types/contract/src/settingsLabels.d.ts +3 -0
  81. package/dist/types/contract/src/slugs.d.ts +6 -0
  82. package/dist/types/{cms-contract → contract}/src/transfer.d.ts +3 -3
  83. package/dist/types/contract/src/trial.d.ts +10 -0
  84. package/dist/types/contract/src/versions.d.ts +9 -0
  85. package/dist/types/{cms-contract → contract}/src/webhooks.d.ts +33 -58
  86. package/dist/types/contract/src/workflow.d.ts +49 -0
  87. package/dist/types/contract/src/workspaceItems.d.ts +73 -0
  88. package/dist/types/contract/src/workspacePaths.d.ts +4 -0
  89. package/dist/types/{body → rich-text}/src/declared.d.ts +2 -2
  90. package/dist/types/{body → rich-text}/src/embed.d.ts +1 -1
  91. package/dist/types/{body → rich-text}/src/labels/ja.d.ts +2 -2
  92. package/dist/types/{body → rich-text}/src/profile.d.ts +1 -1
  93. package/dist/types/{model → schema}/src/audience.d.ts +11 -11
  94. package/dist/types/schema/src/brand.d.ts +5 -0
  95. package/dist/types/{model → schema}/src/capabilities.d.ts +5 -5
  96. package/dist/types/{model → schema}/src/changes.d.ts +6 -6
  97. package/dist/types/{model → schema}/src/check.d.ts +2 -2
  98. package/dist/types/{model/src/model.d.ts → schema/src/collection.d.ts} +25 -23
  99. package/dist/types/{platform/src/defaultModel.d.ts → schema/src/defaultSchema.d.ts} +4 -3
  100. package/dist/types/{model/src/asset.d.ts → schema/src/file.d.ts} +16 -16
  101. package/dist/types/{model → schema}/src/image.d.ts +3 -3
  102. package/dist/types/{model → schema}/src/index.d.ts +11 -10
  103. package/dist/types/{model → schema}/src/input.d.ts +3 -3
  104. package/dist/types/{model → schema}/src/integrity.d.ts +1 -1
  105. package/dist/types/{model → schema}/src/labels/en.d.ts +8 -7
  106. package/dist/types/{model → schema}/src/labels/ja.d.ts +9 -8
  107. package/dist/types/schema/src/legacy.d.ts +2 -0
  108. package/dist/types/{model → schema}/src/media.d.ts +1 -1
  109. package/dist/types/{model → schema}/src/mediaUrl.d.ts +5 -5
  110. package/dist/types/{model → schema}/src/page.d.ts +2 -2
  111. package/dist/types/{model → schema}/src/problems.d.ts +14 -13
  112. package/dist/types/{model → schema}/src/refs.d.ts +1 -1
  113. package/dist/types/{model → schema}/src/rules.d.ts +2 -2
  114. package/dist/types/{model → schema}/src/schema.d.ts +10 -10
  115. package/dist/types/{model → schema}/src/selfOps.d.ts +1 -1
  116. package/dist/types/schema/src/typesSource.d.ts +16 -0
  117. package/dist/types/{model → schema}/src/values.d.ts +2 -2
  118. package/dist/types/sdk/src/analytics.d.ts +2 -2
  119. package/dist/types/sdk/src/app.d.ts +44 -16
  120. package/dist/types/sdk/src/bridge.d.ts +12 -12
  121. package/dist/types/sdk/src/customers.d.ts +14 -20
  122. package/dist/types/sdk/src/delegation.d.ts +39 -0
  123. package/dist/types/sdk/src/delivery/client.d.ts +11 -10
  124. package/dist/types/sdk/src/delivery/fields.d.ts +2 -2
  125. package/dist/types/sdk/src/delivery/index.d.ts +2 -2
  126. package/dist/types/sdk/src/delivery/media.d.ts +17 -3
  127. package/dist/types/sdk/src/delivery/query.d.ts +1 -1
  128. package/dist/types/sdk/src/delivery/schema.d.ts +4 -4
  129. package/dist/types/sdk/src/delivery/values.d.ts +6 -6
  130. package/dist/types/sdk/src/delivery.d.ts +3 -3
  131. package/dist/types/sdk/src/i18n.d.ts +11 -11
  132. package/dist/types/sdk/src/integrations.d.ts +10 -10
  133. package/dist/types/sdk/src/{body.d.ts → rich-text.d.ts} +2 -2
  134. package/dist/types/sdk/src/schema.d.ts +5 -21
  135. package/dist/types/sdk/src/site.d.ts +1 -1
  136. package/dist/types/sdk/src/types.d.ts +21 -0
  137. package/dist/{schema-BPHL7Qr-.js → types-B77qvqPJ.js} +5 -4
  138. package/dist/types.d.ts +1 -0
  139. package/dist/types.js +1 -0
  140. package/dist/{typesSource-bO0jFw1I.js → typesSource-CWybQYus.js} +58 -12
  141. package/package.json +12 -12
  142. package/dist/apps-9u4XMi7E.js +0 -114
  143. package/dist/body.d.ts +0 -1
  144. package/dist/embed-R-OvDYAw.js +0 -90
  145. package/dist/model.d.ts +0 -1
  146. package/dist/model.js +0 -345
  147. package/dist/types/analytics/src/index.d.ts +0 -5
  148. package/dist/types/analytics/src/schedule.d.ts +0 -2
  149. package/dist/types/analytics/src/shared.d.ts +0 -21
  150. package/dist/types/analytics/src/source.d.ts +0 -19
  151. package/dist/types/analytics/src/store.d.ts +0 -24
  152. package/dist/types/model/src/brand.d.ts +0 -25
  153. package/dist/types/model/src/legacy.d.ts +0 -2
  154. package/dist/types/model/src/typesSource.d.ts +0 -8
  155. package/dist/types/sdk/src/model.d.ts +0 -5
  156. /package/dist/types/{cms-contract → contract}/src/appProblems.d.ts +0 -0
  157. /package/dist/types/{cms-contract → contract}/src/consents.d.ts +0 -0
  158. /package/dist/types/{cms-contract → contract}/src/customerLabels.d.ts +0 -0
  159. /package/dist/types/{analytics → contract}/src/day.d.ts +0 -0
  160. /package/dist/types/{cms-contract → contract}/src/functionLabels.d.ts +0 -0
  161. /package/dist/types/{cms-contract → contract}/src/permissionLabels.d.ts +0 -0
  162. /package/dist/types/{cms-contract → contract}/src/siteArtifact.d.ts +0 -0
  163. /package/dist/types/{cms-contract → contract}/src/siteDeclaration.d.ts +0 -0
  164. /package/dist/types/{analytics/src/view.d.ts → contract/src/viewEvent.d.ts} +0 -0
  165. /package/dist/types/{cms-contract → contract}/src/views.d.ts +0 -0
  166. /package/dist/types/{cms-contract → contract}/src/webhookLabels.d.ts +0 -0
  167. /package/dist/types/{body → rich-text}/src/components.d.ts +0 -0
  168. /package/dist/types/{body → rich-text}/src/derive.d.ts +0 -0
  169. /package/dist/types/{body → rich-text}/src/description.d.ts +0 -0
  170. /package/dist/types/{body → rich-text}/src/href.d.ts +0 -0
  171. /package/dist/types/{body → rich-text}/src/html.d.ts +0 -0
  172. /package/dist/types/{body → rich-text}/src/index.d.ts +0 -0
  173. /package/dist/types/{body → rich-text}/src/inline.d.ts +0 -0
  174. /package/dist/types/{body → rich-text}/src/labels/en.d.ts +0 -0
  175. /package/dist/types/{body → rich-text}/src/library.d.ts +0 -0
  176. /package/dist/types/{body → rich-text}/src/markdown.d.ts +0 -0
  177. /package/dist/types/{body → rich-text}/src/normalize.d.ts +0 -0
  178. /package/dist/types/{body → rich-text}/src/problems.d.ts +0 -0
  179. /package/dist/types/{body → rich-text}/src/render.d.ts +0 -0
  180. /package/dist/types/{body → rich-text}/src/schema.d.ts +0 -0
  181. /package/dist/types/{body → rich-text}/src/standard.d.ts +0 -0
  182. /package/dist/types/{body → rich-text}/src/types.d.ts +0 -0
  183. /package/dist/types/{model → schema}/src/contact.d.ts +0 -0
  184. /package/dist/types/{model → schema}/src/json.d.ts +0 -0
  185. /package/dist/types/{model → schema}/src/screens.d.ts +0 -0
  186. /package/dist/types/{model → schema}/src/time.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import type { ContentModel, Collection, FieldDef } from '../../../model/src/index.js';
1
+ import type { CollectionSchema, Collection, FieldDef } from '../../../schema/src/index.js';
2
2
  import type { GrantedField, 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'];
@@ -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;
@@ -1,8 +1,8 @@
1
1
  export { cachedDelivery, memoryDeliveryCache, type DeliveryCache } from './cache.js';
2
2
  export { readChanges, type Change, type ChangesPage } from './changes.js';
3
3
  export { createDeliveryClient, DELIVERY_PATH, DeliveryError, subPath, type BundleResult, type Delivery, type DeliveryClient, type Prefetched } from './client.js';
4
- export { deliveredImageUrl, mediaOf, type ImageUrl, type MediaOf } from './media.js';
5
- export { imageParamsOf, parseMediaPath, signMediaUrl, withImageParams, type DeliveredAsset, type ImageParams, type MediaPath } from '../../../model/src/index.js';
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';
6
6
  export type { FieldPath, Selected } from './fields.js';
7
7
  export { listParams, type ListFilter, type ListQuery, type Page } from './query.js';
8
8
  export { createDeliveryClock, fieldOf, limitOf, optionLabels, pagePath, type DeliveryClock } from './schema.js';
@@ -1,13 +1,27 @@
1
- import { type CropRect, type Media } from '../../../model/src/index.js';
1
+ import { type CropRect, type Media } from '../../../schema/src/index.js';
2
+ /** 実体の配信の URL の材料(project はプロジェクトの ID(base32)、id は実体の ID(UUID)。width・height は画像の元の画素) */
3
+ export type MediaUrlInput = Readonly<{
4
+ project: string;
5
+ id: string;
6
+ mimeType: string;
7
+ width?: number;
8
+ height?: number;
9
+ }>;
10
+ /**
11
+ * 実体の ID から配信の URL を作る(origin は配信のオリジン、#776)
12
+ * - パスのプロジェクトは base32 の正の形、実体は UUID。配信 API の url と同じ値になる
13
+ * - 配信しない形式、ID の形が違うとき(プロジェクトの UUID の形を含む)は null。非公開の実体は signMediaUrl で署名してから使う
14
+ */
15
+ export declare function mediaUrlOf(origin: string, { project, id, mimeType, width, height }: MediaUrlInput): string | null;
2
16
  /** 配信する画像の URL(元の URL と、元画像の画素での切り抜きの範囲から、配信の側で変換する URL) */
3
17
  export type ImageUrl = (src: string, rect?: CropRect) => string;
4
18
  /** 配信 URL の画像の切り抜き(クエリ rect、範囲なしは元の URL) */
5
19
  export declare const deliveredImageUrl: ImageUrl;
6
20
  /** 実体から表示の素材(見つからない実体はなし) */
7
- export type MediaOf = (asset: unknown) => Media | undefined;
21
+ export type MediaOf = (file: unknown) => Media | undefined;
8
22
  /**
9
23
  * 実体から表示の素材への変換(動画は代わりの画像も)
10
- * - URL: 実体の url、なしは base/<ID>(base は実体の URL の前半)
24
+ * - URL: 実体の url、なしは base/<ID>(base は実体の URL の前半、手元の CMS の /media。ID は実体の UUID)
11
25
  * - 画像の変換: imageUrl で画像(動画の実体は除く)を変換の URL に、url のある実体の既定は deliveredImageUrl、切り抜きは切り抜いた画像の URL・寸法・見せたい点
12
26
  * - url も imageUrl もない: 元の画像のまま(手元の開発)
13
27
  */
@@ -1,4 +1,4 @@
1
- import type { Collection, FieldDef } from '../../../model/src/index.js';
1
+ import type { Collection, FieldDef } from '../../../schema/src/index.js';
2
2
  import type { FieldPath } from './fields.js';
3
3
  import type { GrantedField, FieldsOf, Item, SingleValue, UndeliveredField } from './values.js';
4
4
  /** 範囲の指定(両端を含む) */
@@ -1,12 +1,12 @@
1
- import { type Clock, type ContentModel, type DateString, type FieldDef, type PageRecord } from '../../../model/src/index.js';
1
+ import { type Clock, type CollectionSchema, type DateString, type FieldDef, type PageRecord } from '../../../schema/src/index.js';
2
2
  /** 選択肢の項目から表示名の表(値 → 表示名、key はまとまりの中なら `links.kind` の形、選択肢の項目でなければ空) */
3
- export declare const optionLabels: <K extends string = string>(schema: ContentModel, collection: string, key: string) => Readonly<Record<K, string>>;
3
+ export declare const optionLabels: <K extends string = string>(schema: CollectionSchema, collection: string, key: string) => Readonly<Record<K, string>>;
4
4
  /** コレクションの項目(なければ例外: 導入先の設定の誤り) */
5
- export declare function fieldOf(schema: ContentModel, collection: string, key: string): FieldDef;
5
+ export declare function fieldOf(schema: CollectionSchema, collection: string, key: string): FieldDef;
6
6
  /** 項目の宣言の上限(宣言がなければ例外) */
7
7
  export declare function limitOf(field: FieldDef, name: 'maxItems' | 'maxLength'): number;
8
8
  /** ページのパス(コレクションの宣言 pages から、ページのないコレクションは例外) */
9
- export declare function pagePath(schema: ContentModel, collection: string, record: PageRecord): string;
9
+ export declare function pagePath(schema: CollectionSchema, collection: string, record: PageRecord): string;
10
10
  /** プロジェクトのタイムゾーンでの日時の変換(表示用の日付と日時の組 dated を含む) */
11
11
  export type DeliveryClock = Clock & Readonly<{
12
12
  /** 日時の項目から、表示用のタイムゾーンの日付と `ISO 8601` の日時(日時の形でない値はそのまま) */
@@ -1,5 +1,5 @@
1
- import type { Body } from '../../../body/src/index.js';
2
- import type { Collection, DateString, DeliveredAsset, FieldDef } from '../../../model/src/index.js';
1
+ import type { Body } from '../../../rich-text/src/index.js';
2
+ import type { Collection, DateString, DeliveredFile, FieldDef } from '../../../schema/src/index.js';
3
3
  /** 配信 API の1件の値(id・slug・項目の key・メタ情報 _meta) */
4
4
  export type Item = Readonly<Record<string, unknown>>;
5
5
  /** 参照の値(参照先のレコードの id とスラッグ、突き合わせは id で) */
@@ -26,10 +26,10 @@ export type SingleValue<F extends FieldDef> = F extends {
26
26
  } ? O['value'] : F extends {
27
27
  type: 'reference';
28
28
  } ? RecordRef : F extends {
29
- type: 'media';
30
- } ? DeliveredAsset | null : F extends {
29
+ type: 'file';
30
+ } ? DeliveredFile | null : F extends {
31
31
  type: 'rich_text';
32
- } ? Body<DeliveredAsset | null> : F extends {
32
+ } ? Body<DeliveredFile | null> : F extends {
33
33
  type: 'group';
34
34
  fields: readonly (infer G extends FieldDef)[];
35
35
  } ? GroupValue<G> : unknown;
@@ -38,7 +38,7 @@ type GroupValue<G extends FieldDef> = {
38
38
  readonly [K in G as K['key']]: FieldValue<K>;
39
39
  };
40
40
  /**
41
- * 項目の値(種類ごと: 文字は string、日付は YYYY-MM-DD、日時は `ISO 8601` の UTC、参照は参照先の { id, slug }、メディアは実体、本文は標準のブロック)
41
+ * 項目の値(種類ごと: 文字は string、日付は YYYY-MM-DD、日時は `ISO 8601` の UTC、参照は参照先の { id, slug }、ファイルは実体、本文は標準のブロック)
42
42
  * - multiple の項目: 値の配列
43
43
  * - 値なし: null
44
44
  */
@@ -1,3 +1,3 @@
1
- export { cachedDelivery, createDeliveryClient, createDeliveryClock, deliveredImageUrl, DELIVERY_PATH, DeliveryError, fieldOf, imageParamsOf, limitOf, listParams, mediaOf, memoryDeliveryCache, optionLabels, pagePath, parseMediaPath, readChanges, signMediaUrl, subPath, withImageParams } from './delivery/index.js';
2
- export type { Issue, IssueSeverity } from '../../cms-contract/src/errors.js';
3
- export type { BundleResult, Change, ChangesPage, DeliveredAsset, Delivery, DeliveryCache, DeliveryClient, DeliveryClock, FieldValue, ImageParams, ImageUrl, Item, ItemMeta, ItemOf, FieldPath, ListFilter, ListQuery, MediaOf, MediaPath, Page, Prefetched, RecordRef, Selected } from './delivery/index.js';
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';
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';
@@ -1,12 +1,12 @@
1
- export { BASE_LOCALE, chooseLocale, createTranslator, formatMessage, LOCALES, problemMessage, problemOf, problemText } from '../../i18n/src/index.js';
1
+ export { BASE_LOCALE, chooseLocale, createTranslator, formatMessage, LOCALES, problemMessage, problemOf, problemText, problemTextFactory } from '../../i18n/src/index.js';
2
2
  export type { Catalog, Locale, MessageAt, MessageKey, Messages, ParamsArg, ParamsOf, ParamValue, Problem, Translate } from '../../i18n/src/index.js';
3
- export { ERROR_MESSAGES, errorMessageOf, errorTitle } from '../../cms-contract/src/errorLabels.js';
4
- export { ERROR_MESSAGES_EN } from '../../cms-contract/src/errorLabelsEn.js';
5
- export { API_ISSUE_MESSAGES } from '../../cms-contract/src/issueLabels.js';
6
- export { API_ISSUE_MESSAGES_EN } from '../../cms-contract/src/issueLabelsEn.js';
7
- export type { ErrorCatalog } from '../../cms-contract/src/errorLabels.js';
8
- export { importProblemLabel, issueLabel, labelTableProblems, PROBLEM_MESSAGES, PROBLEM_MESSAGES_EN, problemEnglish, problemLabel } from '../../cms-contract/src/problems.js';
9
- export { MODEL_PROBLEM_MESSAGES } from '../../model/src/labels/ja.js';
10
- export { MODEL_PROBLEM_MESSAGES_EN } from '../../model/src/labels/en.js';
11
- export { BODY_PROBLEM_MESSAGES } from '../../body/src/labels/ja.js';
12
- export { BODY_PROBLEM_MESSAGES_EN } from '../../body/src/labels/en.js';
3
+ export { ERROR_MESSAGES, errorMessageOf, errorTitle } from '../../contract/src/errorLabels.js';
4
+ export { ERROR_MESSAGES_EN } from '../../contract/src/errorLabelsEn.js';
5
+ export { API_ISSUE_MESSAGES } from '../../contract/src/issueLabels.js';
6
+ export { API_ISSUE_MESSAGES_EN } from '../../contract/src/issueLabelsEn.js';
7
+ export type { ErrorCatalog } from '../../contract/src/errorLabels.js';
8
+ export { importProblemLabel, issueLabel, labelTableProblems, PROBLEM_MESSAGES, PROBLEM_MESSAGES_EN, problemEnglish, problemLabel } from '../../contract/src/problems.js';
9
+ export { SCHEMA_PROBLEM_MESSAGES } from '../../schema/src/labels/ja.js';
10
+ export { SCHEMA_PROBLEM_MESSAGES_EN } from '../../schema/src/labels/en.js';
11
+ export { BODY_PROBLEM_MESSAGES } from '../../rich-text/src/labels/ja.js';
12
+ export { BODY_PROBLEM_MESSAGES_EN } from '../../rich-text/src/labels/en.js';
@@ -1,22 +1,22 @@
1
1
  import { type SigningSecrets } from '../../access/src/index.js';
2
- import { type SessionTokenClaims } from '../../cms-contract/src/bridge.js';
3
- import { type EmbedContext } from '../../cms-contract/src/embeds.js';
2
+ import { type SessionTokenClaims } from '../../contract/src/bridge.js';
3
+ import { type EmbedContext } from '../../contract/src/embeds.js';
4
4
  export { openValue } from '../../access/src/index.js';
5
5
  export type { SigningSecrets } from '../../access/src/index.js';
6
- export { SESSION_TOKEN } from '../../cms-contract/src/bridge.js';
7
- export { EMBED_CONTEXT_NEXT_PARAM, EMBED_CONTEXT_PARAM, EMBED_CONTEXT_REFRESH_SEC, EMBED_MESSAGES, EMBED_PLACEMENTS } from '../../cms-contract/src/embeds.js';
8
- export { FUNCTION_HOOKS } from '../../cms-contract/src/functions.js';
9
- export type { SessionTokenClaims } from '../../cms-contract/src/bridge.js';
10
- export type { EmbedContext, EmbedMessage, EmbedPlacement } from '../../cms-contract/src/embeds.js';
11
- export type { FunctionHook, FunctionIssue, FunctionRef, FunctionRequest, ListCell, ListCellTone, ListColumnRequest, ListColumnResponse, PublishCheckRequest, PublishCheckResponse, SaveCheckRequest, SaveCheckResponse } from '../../cms-contract/src/functions.js';
12
- export type { InstallationUninstalledData, WebhookAction, WebhookBody, WebhookChangeAction, WebhookChangeBody, WebhookEvent, WebhookModuleBody, WebhookVersion } from '../../cms-contract/src/webhooks.js';
6
+ export { SESSION_TOKEN } from '../../contract/src/bridge.js';
7
+ export { EMBED_CONTEXT_NEXT_PARAM, EMBED_CONTEXT_PARAM, EMBED_CONTEXT_REFRESH_SEC, EMBED_MESSAGES, EMBED_PLACEMENTS } from '../../contract/src/embeds.js';
8
+ export { FUNCTION_HOOKS } from '../../contract/src/functions.js';
9
+ export type { SessionTokenClaims } from '../../contract/src/bridge.js';
10
+ export type { EmbedContext, EmbedMessage, EmbedPlacement } from '../../contract/src/embeds.js';
11
+ export type { FunctionHook, FunctionIssue, FunctionRef, FunctionRequest, ListCell, ListCellTone, ListColumnRequest, ListColumnResponse, PublishCheckRequest, PublishCheckResponse, SaveCheckRequest, SaveCheckResponse } from '../../contract/src/functions.js';
12
+ export type { InstallationDeletedData, WebhookAction, WebhookBody, WebhookChangeAction, WebhookEvent, WebhookMessage, WebhookAppBody, WebhookRecordData, WebhookRecordType } from '../../contract/src/webhooks.js';
13
13
  /** 文脈の検証の条件(embed: 自分の登録の ID。指定すると、登録の ID が違う文脈と登録の ID のない文脈を null にする) */
14
14
  export type EmbedContextOptions = Readonly<{
15
15
  embed?: string;
16
16
  }>;
17
17
  /** 外の画面の URL の文脈(クエリ ctx と、鍵の移行の期間の ctx_next のどちらかが鍵で開けば文脈、なければ null) */
18
18
  export declare function openEmbedContext(secret: SigningSecrets, url: string | URL, now?: number, options?: EmbedContextOptions): Promise<EmbedContext | null>;
19
- /** 管理画面が取り直して送る context のメッセージの文脈(ctxNext を先に、どちらかが鍵で開けば文脈、なければ null) */
19
+ /** ワークスペースが取り直して送る context のメッセージの文脈(ctxNext を先に、どちらかが鍵で開けば文脈、なければ null) */
20
20
  export declare function openEmbedContextMessage(secret: SigningSecrets, message: Readonly<{
21
21
  ctx?: string | null;
22
22
  ctxNext?: string | null;
@@ -1,2 +1,2 @@
1
- export { blockSchemaOf, bodyToHtml, cellParagraphs, citesOf, DESCRIPTION_MAX, descriptionOf, EMBED_PROVIDERS, embedOfUrl, embedSrcOf, excerptOf, isSafeCssValue, isSafeHref, isTableCell, linksOf, plainOf, READING_SPEED, readMinOf } from '../../body/src/index.js';
2
- export type { Align, Block, Body, BodyProfile, Cell, ComponentBlock, DeclaredComponent, EmbedProvider, EmbedTarget, HeadingLevel, ImageAlign, Inline, InlineComponent, Link, List, ListItem, Mark, Named, NamedStyle, NamedValue, PropSchema, PropsSchema, PropType, RenderedImage, RenderOptions, Rich, StandardBlock, TableCell, Text, TextStyle } from '../../body/src/index.js';
1
+ export { blockSchemaOf, bodyToHtml, cellParagraphs, citesOf, DESCRIPTION_MAX, descriptionOf, EMBED_PROVIDERS, embedOfUrl, embedSrcOf, excerptOf, isSafeCssValue, isSafeHref, isTableCell, linksOf, plainOf, READING_SPEED, readMinOf } from '../../rich-text/src/index.js';
2
+ export type { Align, Block, Body, BodyProfile, Cell, ComponentBlock, DeclaredComponent, EmbedProvider, EmbedTarget, HeadingLevel, ImageAlign, Inline, InlineComponent, Link, List, ListItem, Mark, Named, NamedStyle, NamedValue, PropSchema, PropsSchema, PropType, RenderedImage, RenderOptions, Rich, StandardBlock, TableCell, Text, TextStyle } from '../../rich-text/src/index.js';
@@ -1,21 +1,5 @@
1
- import { type Collection } from '../../model/src/index.js';
2
- /**
3
- * tunasand types の終了の状態
4
- * - drift: --check でファイルが CMS のスキーマと違う
5
- * - failed: 引数と鍵の不足、CMS の拒否(4xx)、応答の形の誤り、ファイルの読み書きの失敗
6
- * - unreachable: CMS に届かない(接続の失敗、5xx)
7
- */
8
- export declare const TYPES_EXIT_CODES: {
9
- readonly ok: 0;
10
- readonly drift: 1;
11
- readonly failed: 2;
12
- readonly unreachable: 3;
13
- };
14
- /**
15
- * 配信 API の型の一覧(/collections、表示名・選択肢・上限・ページの URL の形を含む。実行時に読む値もここから)
16
- * - 例外: 2xx でなければ `fetch_failed: <状態> <本文>`、本文に collections がなければ `invalid_response`
17
- * - 接続の失敗は fetcher の例外のまま
18
- */
19
- export declare function fetchDeliveredCollections(url: string, apiKey: string, fetcher?: typeof fetch): Promise<readonly Collection[]>;
20
- /** CLI の本体(戻り値は終了の状態 TYPES_EXIT_CODES、失敗は例外にせず標準エラーと終了の状態で返す) */
21
- export declare function runTypesCli(argv: readonly string[], env: Readonly<Record<string, string | undefined>>, fetcher?: typeof fetch): Promise<number>;
1
+ export { collectionOf, coverPosition, coverStart, createClock, cropRect, croppedHotspot, fileRefSchema, IMAGE_TYPE, initialValueOf, isDateOnly, isStoredCollection, mediaSchema, objectPosition, optionLabelOf, optionsOf, pagePathOf, parseSchema, parseScreens, publicPathOf, requiredPrimaryCollectionOf, roleFieldOf, dateRoleFieldsOf, sourcesFieldOf, sourceIdsOf, usesReview, stillOf, typesSourceOf, valueFieldsOf, VIDEO_TYPE } from '../../schema/src/index.js';
2
+ export type { File, FileRef, Clock, Collection, CollectionSchema, Crop, CropRect, DateString, FieldDef, Hotspot, LocalImage, Media, PageDef, PageRecord, ScreenSettings } from '../../schema/src/index.js';
3
+ export { CONFIG_FORMAT } from '../../contract/src/transfer.js';
4
+ export type { ConfigBundle } from '../../contract/src/transfer.js';
5
+ export { DEFAULT_SCHEMA, DEFAULT_SCREENS } from '../../schema/src/defaultSchema.js';
@@ -1,4 +1,4 @@
1
- import { type SiteModuleType } from '../../cms-contract/src/siteArtifact.js';
1
+ import { type SiteModuleType } from '../../contract/src/siteArtifact.js';
2
2
  export declare const SITE_EXIT_CODES: {
3
3
  readonly ok: 0;
4
4
  readonly failed: 1;
@@ -0,0 +1,21 @@
1
+ import { type Collection } from '../../schema/src/index.js';
2
+ /**
3
+ * tunasand types の終了の状態
4
+ * - drift: --check でファイルが CMS のスキーマと違う
5
+ * - failed: 引数と鍵の不足、CMS の拒否(4xx)、応答の形の誤り、SDK が生成できない項目の型、ファイルの読み書きの失敗
6
+ * - unreachable: CMS に届かない(接続の失敗、5xx)
7
+ */
8
+ export declare const TYPES_EXIT_CODES: {
9
+ readonly ok: 0;
10
+ readonly drift: 1;
11
+ readonly failed: 2;
12
+ readonly unreachable: 3;
13
+ };
14
+ /**
15
+ * 配信 API の型の一覧(/collections、表示名・選択肢・上限・ページの URL の形を含む。実行時に読む値もここから)
16
+ * - 例外: 2xx でなければ `fetch_failed: <状態> <本文>`、本文に collections がなければ `invalid_response`
17
+ * - 接続の失敗は fetcher の例外のまま
18
+ */
19
+ export declare function fetchDeliveredCollections(url: string, apiKey: string, fetcher?: typeof fetch): Promise<readonly Collection[]>;
20
+ /** CLI の本体(戻り値は終了の状態 TYPES_EXIT_CODES、失敗は例外にせず標準エラーと終了の状態で返す) */
21
+ export declare function runTypesCli(argv: readonly string[], env: Readonly<Record<string, string | undefined>>, fetcher?: typeof fetch): Promise<number>;
@@ -1,11 +1,11 @@
1
- import { t as typesSourceOf } from "./typesSource-bO0jFw1I.js";
1
+ import { n as typesSourceOf, t as UnknownFieldTypeError } from "./typesSource-CWybQYus.js";
2
2
  import { t as DELIVERY_PATH } from "./client-Derrexwr.js";
3
3
  import { readFileSync, writeFileSync } from "node:fs";
4
- // src/schema.ts
4
+ // src/types.ts
5
5
  /**
6
6
  * tunasand types の終了の状態
7
7
  * - drift: --check でファイルが CMS のスキーマと違う
8
- * - failed: 引数と鍵の不足、CMS の拒否(4xx)、応答の形の誤り、ファイルの読み書きの失敗
8
+ * - failed: 引数と鍵の不足、CMS の拒否(4xx)、応答の形の誤り、SDK が生成できない項目の型、ファイルの読み書きの失敗
9
9
  * - unreachable: CMS に届かない(接続の失敗、5xx)
10
10
  */
11
11
  const TYPES_EXIT_CODES = {
@@ -22,6 +22,7 @@ const MESSAGES = {
22
22
  fetchFailed: (status, body) => `fetch_failed: ${status} ${body.slice(0, 200)}`,
23
23
  invalidResponse: "invalid_response: delivery API /collections response has no collections",
24
24
  unreachable: (url, reason) => `cms_unreachable: ${url} ${reason}`,
25
+ unknownFieldType: (path, type) => `unknown_field_type: ${path} の型 ${type} をこの SDK は生成できない(@tunasand/sdk を上げる)`,
25
26
  drift: (file) => `schema_drift: ${file} が CMS のスキーマと違う(tunasand types --out ${file} で生成し直す)`,
26
27
  upToDate: (file) => `up_to_date: ${file}`,
27
28
  written: (file) => `written: ${file}`
@@ -108,7 +109,7 @@ async function runTypesCli(argv, env, fetcher = fetch) {
108
109
  try {
109
110
  return writeOrCheck(out, typesSourceOf({ collections }), check);
110
111
  } catch (e) {
111
- console.error(messageOf(e));
112
+ console.error(e instanceof UnknownFieldTypeError ? MESSAGES.unknownFieldType(e.path, e.fieldType) : messageOf(e));
112
113
  return TYPES_EXIT_CODES.failed;
113
114
  }
114
115
  }
@@ -0,0 +1 @@
1
+ export * from './types/sdk/src/types.js';
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { t as TYPES_EXIT_CODES, n as fetchDeliveredCollections, r as runTypesCli } from "./types-B77qvqPJ.js";
@@ -1,5 +1,5 @@
1
- import { _ as isDeliveredAudience, g as innerAudienceOf, l as audienceOf, y as isPrivateCollection } from "./model-pmXzGX12.js";
2
- // ../model/src/values.ts
1
+ import { _ as innerAudienceOf, l as audienceOf, v as isDeliveredAudience, x as isPrivateCollection } from "./collection-BEOxeISR.js";
2
+ // ../schema/src/values.ts
3
3
  /** まとまりの中の配信する項目(外側の見える範囲 outer の中で、本人とスタッフの項目を除く) */
4
4
  const deliveredInner = (fields, outer) => fields.flatMap((f) => {
5
5
  const own = innerAudienceOf(f, outer);
@@ -18,13 +18,54 @@ const deliveredFields = (collection) => collection.fields.flatMap((f) => {
18
18
  fields: deliveredInner(f.fields, own)
19
19
  } : f];
20
20
  });
21
- // ../model/src/typesSource.ts
21
+ /** コレクションの値の項目(参照の項目を除く) */
22
+ const valueFieldsOf = (collection) => collection.fields.filter((f) => f.type !== "reference");
23
+ // ../schema/src/typesSource.ts
22
24
  /** 生成した型の定義が SDK から読む型の import の元 */
23
25
  const SDK = "@tunasand/sdk";
24
26
  /** 型の import のレコード(指定は JSON の文字列の形) */
25
27
  const importLine = (names, spec) => `import type { ${names.join(", ")} } from ${JSON.stringify(spec)};`;
26
28
  /** プロパティの名前(識別子でない key は JSON の文字列の形) */
27
29
  const propertyName = (key) => /^[A-Za-z_$][\w$]*$/.test(key) ? key : JSON.stringify(key);
30
+ /** 生成できる項目の型(singleOf の分岐と同じ。配信 API が知らない型を返したら UnknownFieldTypeError) */
31
+ const GENERATED_TYPES = {
32
+ text: true,
33
+ long_text: true,
34
+ datetime: true,
35
+ customer: true,
36
+ email: true,
37
+ phone: true,
38
+ url: true,
39
+ date: true,
40
+ reference: true,
41
+ number: true,
42
+ boolean: true,
43
+ select: true,
44
+ file: true,
45
+ rich_text: true,
46
+ group: true
47
+ };
48
+ /** 生成できない項目の型(code は unknown_field_type、path はコレクションのスラッグからの項目の key の道) */
49
+ var UnknownFieldTypeError = class extends Error {
50
+ code = "unknown_field_type";
51
+ path;
52
+ fieldType;
53
+ constructor(path, fieldType) {
54
+ super(`unknown_field_type: ${path} (${fieldType})`);
55
+ this.path = path;
56
+ this.fieldType = fieldType;
57
+ }
58
+ };
59
+ /** 生成できない型の最初の項目(なければ null) */
60
+ function unknownFieldOf(fields, at) {
61
+ for (const f of fields) {
62
+ const path = `${at}.${f.key}`;
63
+ if (!Object.hasOwn(GENERATED_TYPES, f.type)) return new UnknownFieldTypeError(path, String(f.type));
64
+ const inner = f.type === "group" ? unknownFieldOf(f.fields, path) : null;
65
+ if (inner) return inner;
66
+ }
67
+ return null;
68
+ }
28
69
  const pascal = (id) => id.replace(/(^|[-_])(\w)/g, (_, __, ch) => ch.toUpperCase());
29
70
  /** 項目の1つ分の値の型(SDK の SingleValue と同じ) */
30
71
  function singleOf(f, indent) {
@@ -41,8 +82,8 @@ function singleOf(f, indent) {
41
82
  case "number": return "number";
42
83
  case "boolean": return "boolean";
43
84
  case "select": return f.options.map((o) => JSON.stringify(o.value)).join(" | ") || "string";
44
- case "media": return "DeliveredAsset | null";
45
- case "rich_text": return "Body<DeliveredAsset | null>";
85
+ case "file": return "DeliveredFile | null";
86
+ case "rich_text": return "Body<DeliveredFile | null>";
46
87
  case "group": return `{\n${fieldsOf(f.fields, `${indent} `, () => false)}\n${indent}}`;
47
88
  }
48
89
  }
@@ -58,25 +99,30 @@ const kindsOf = (fields) => fields.flatMap((f) => [f.type, ...f.type === "group"
58
99
  const fieldsOf = (fields, indent, optional) => fields.map((f) => `${indent}readonly ${propertyName(f.key)}${optional(f) ? "?" : ""}: ${valueOf(f, indent)};`).join("\n");
59
100
  const typeOf = (t) => `export type ${pascal(t.slug)} = Readonly<{\n id: string;\n slug: string;\n _meta: ItemMeta;\n${fieldsOf(deliveredFields(t), " ", (f) => audienceOf(f, t) === "granted")}\n}>;`;
60
101
  /**
61
- * スキーマから配信 API の値の型の定義(TypeScript のモジュールの文)
102
+ * スキーマから配信 API の値の型の定義(TypeScript のアプリの文)
62
103
  * - コレクションごとに `export type <PascalCase のコレクションのスラッグ>`
63
104
  * - 全体の対応 `CmsTypes`(キーはスラッグ)とスラッグの一覧 `COLLECTION_SLUGS`
64
105
  * - types: 配信するコレクションだけ(メディアのコレクションを除いた一覧、配信 API の `/collections` の値)。非公開のコレクションは渡されても除く
106
+ * - 例外: 生成できない項目の型(CMS が SDK より新しい型を返した)は UnknownFieldTypeError
65
107
  */
66
- function typesSourceOf(model) {
67
- const collections = model.collections.filter((t) => !isPrivateCollection(t)).sort((a, b) => a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0);
108
+ function typesSourceOf(collectionSchema) {
109
+ const collections = collectionSchema.collections.filter((t) => !isPrivateCollection(t)).sort((a, b) => a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0);
110
+ for (const t of collections) {
111
+ const unknown = unknownFieldOf(deliveredFields(t), t.slug);
112
+ if (unknown) throw unknown;
113
+ }
68
114
  const kinds = new Set(collections.flatMap((t) => kindsOf(deliveredFields(t))));
69
115
  const uses = (kind) => kinds.has(kind);
70
116
  const delivery = [
71
117
  "ItemMeta",
72
- ...uses("media") || uses("rich_text") ? ["DeliveredAsset"] : [],
118
+ ...uses("file") || uses("rich_text") ? ["DeliveredFile"] : [],
73
119
  ...uses("reference") ? ["RecordRef"] : []
74
120
  ].sort();
75
121
  return [
76
122
  "// Generated from the CMS schema (GET /content/v1/collections). Do not edit; regenerate with tunasand types.",
77
123
  importLine(delivery, `${SDK}/delivery`),
78
- ...uses("rich_text") ? [importLine(["Body"], `${SDK}/body`)] : [],
79
- ...uses("date") ? [importLine(["DateString"], `${SDK}/model`)] : [],
124
+ ...uses("rich_text") ? [importLine(["Body"], `${SDK}/rich-text`)] : [],
125
+ ...uses("date") ? [importLine(["DateString"], `${SDK}/schema`)] : [],
80
126
  "",
81
127
  ...collections.flatMap((t) => [typeOf(t), ""]),
82
128
  `export type CmsTypes = {\n${collections.map((t) => ` ${JSON.stringify(t.slug)}: ${pascal(t.slug)};`).join("\n")}\n};`,
@@ -85,4 +131,4 @@ function typesSourceOf(model) {
85
131
  ""
86
132
  ].join("\n");
87
133
  }
88
- export { typesSourceOf as t };
134
+ export { typesSourceOf as n, valueFieldsOf as r, UnknownFieldTypeError as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tunasand/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "tunasand の導入先のサイト向けの SDK(配信 API の取得・本文の型・プレビューの署名・手元の開発の配信 API)",
5
5
  "license": "UNLICENSED",
6
6
  "author": "RYUSENKEI",
@@ -16,13 +16,13 @@
16
16
  "types": "./dist/delivery.d.ts",
17
17
  "default": "./dist/delivery.js"
18
18
  },
19
- "./body": {
20
- "types": "./dist/body.d.ts",
21
- "default": "./dist/body.js"
19
+ "./rich-text": {
20
+ "types": "./dist/rich-text.d.ts",
21
+ "default": "./dist/rich-text.js"
22
22
  },
23
- "./model": {
24
- "types": "./dist/model.d.ts",
25
- "default": "./dist/model.js"
23
+ "./schema": {
24
+ "types": "./dist/schema.d.ts",
25
+ "default": "./dist/schema.js"
26
26
  },
27
27
  "./preview": {
28
28
  "types": "./dist/preview.d.ts",
@@ -56,9 +56,9 @@
56
56
  "types": "./dist/i18n.d.ts",
57
57
  "default": "./dist/i18n.js"
58
58
  },
59
- "./schema": {
60
- "types": "./dist/schema.d.ts",
61
- "default": "./dist/schema.js"
59
+ "./types": {
60
+ "types": "./dist/types.d.ts",
61
+ "default": "./dist/types.js"
62
62
  }
63
63
  },
64
64
  "bin": {
@@ -72,7 +72,7 @@
72
72
  "access": "public"
73
73
  },
74
74
  "dependencies": {
75
- "@ryusenkei/web": "^0.13.0",
75
+ "@ryusenkei/web": "^0.14.0",
76
76
  "htmlparser2": "^10.1.0",
77
77
  "use-intl": "^4.15.1",
78
78
  "zod": "^4.6.7"
@@ -83,7 +83,7 @@
83
83
  "typescript": "^5.9.3"
84
84
  },
85
85
  "scripts": {
86
- "build": "node scripts/build.ts && node scripts/check-dist.ts",
86
+ "build": "node scripts/build.ts && node ../../scripts/check-dist.ts",
87
87
  "typecheck": "tsc"
88
88
  }
89
89
  }
@@ -1,114 +0,0 @@
1
- import { n as fieldDefSchema, t as RESERVED_FIELD_KEYS } from "./schema-UQJWRyfJ.js";
2
- import "./customers-C_vJY2_v.js";
3
- import { z } from "zod";
4
- // ../cms-contract/src/appDependencies.ts
5
- /** 宣言の上限(計画のノードの数は一括の大きさを抑えるため。全部か無しなので分けられない) */
6
- const APP_DEPENDENCY_LIMITS = {
7
- entriesMax: 100,
8
- textMax: 500,
9
- planNodesMax: 20
10
- };
11
- [...RESERVED_FIELD_KEYS];
12
- const PORT_ID = /^[a-z][a-z0-9-]{0,31}:[a-z][a-z0-9_-]{0,63}@[1-9]\d{0,3}$/;
13
- const SETTING_KEY = /^[a-z][a-z0-9_]{0,63}$/;
14
- const COLLECTION_NAME = /^[a-z][a-z0-9_-]{0,63}$/;
15
- const settingKey = z.string().regex(SETTING_KEY);
16
- const settingValue = z.union([
17
- z.boolean(),
18
- z.string().max(APP_DEPENDENCY_LIMITS.textMax),
19
- z.number()
20
- ]);
21
- const list = (item) => z.array(item).max(APP_DEPENDENCY_LIMITS.entriesMax);
22
- const label = z.string().trim().min(1).max(80);
23
- const yen = z.number().int().nonnegative();
24
- const dependencySchema = z.strictObject({
25
- app: z.string().min(1).max(64),
26
- kind: z.enum(["required", "optional"]),
27
- major: z.number().int().positive(),
28
- minVersion: z.number().int().positive().optional(),
29
- defaults: z.record(settingKey, settingValue).optional(),
30
- expose: list(settingKey).optional()
31
- });
32
- const settingSchema = z.strictObject({
33
- key: settingKey,
34
- label,
35
- type: z.enum([
36
- "boolean",
37
- "text",
38
- "number",
39
- "select"
40
- ]),
41
- options: list(z.string().min(1).max(80)).min(1).optional(),
42
- default: settingValue.optional(),
43
- requires: z.string().min(1).max(64).optional()
44
- }).refine((s) => s.type === "select" === (s.options !== void 0), { path: ["options"] }).refine((s) => s.default === void 0 || (s.type === "select" ? s.options?.includes(String(s.default)) : typeof s.default === (s.type === "text" ? "string" : s.type)), { path: ["default"] });
45
- const collectionSchema = z.strictObject({
46
- name: z.string().regex(COLLECTION_NAME),
47
- label,
48
- internal: z.boolean().optional(),
49
- private: z.boolean().optional(),
50
- fields: list(fieldDefSchema)
51
- });
52
- z.object({
53
- major: z.number().int().positive().optional(),
54
- requires: list(dependencySchema).optional(),
55
- uses: list(z.strictObject({
56
- port: z.string().regex(PORT_ID),
57
- required: z.boolean()
58
- })).optional(),
59
- provides: list(z.strictObject({
60
- port: z.string().regex(PORT_ID),
61
- route: z.string().startsWith("/api/").max(2048)
62
- })).optional(),
63
- collections: list(collectionSchema).optional(),
64
- settings: list(settingSchema).optional(),
65
- price: z.strictObject({
66
- setup: yen.optional(),
67
- monthly: yen.optional(),
68
- usage: z.string().trim().min(1).max(APP_DEPENDENCY_LIMITS.textMax).optional(),
69
- currency: z.literal("JPY")
70
- }).optional()
71
- });
72
- // ../cms-contract/src/authorize.ts
73
- /** 判定の操作(コレクションの操作と顧客の操作) */
74
- const OPERATIONS = [
75
- "read",
76
- "read_drafts",
77
- "read_customers",
78
- "create",
79
- "update",
80
- "publish",
81
- "delete",
82
- "submit",
83
- "verify",
84
- "read_state",
85
- "link",
86
- "create_candidate",
87
- "issue_token",
88
- "refresh_token",
89
- "migrate_links",
90
- "read_identities",
91
- "write_grants",
92
- "update_status",
93
- "read_display_name",
94
- "read_consents",
95
- "check_consent",
96
- "write_consents",
97
- "write_suppression",
98
- "read_self",
99
- "create_self",
100
- "update_self",
101
- "delete_self"
102
- ];
103
- // ../cms-contract/src/apps.ts
104
- /**
105
- * アプリの鍵の用途(登録する公開鍵の JWK の use)
106
- * - runtime: アプリの JWT をインストールのトークンに交換する鍵(サイトの実行時に持つ。use なしか sig)
107
- * - deploy: ホスティングするサイトへのアップロードだけに使う鍵(サイトの実行時に持たせない。交換には使えない)
108
- */
109
- const APP_KEY_USES = {
110
- runtime: "sig",
111
- deploy: "tunasand-deploy"
112
- };
113
- new Set(OPERATIONS);
114
- export { APP_KEY_USES as t };
package/dist/body.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './types/sdk/src/body.js';