@ryusenkei/maezae 0.18.0 → 0.19.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 (38) hide show
  1. package/README.md +33 -1
  2. package/dist/analytics.js +30 -14
  3. package/dist/body.js +27 -22
  4. package/dist/client-ClY3gSSd.js +137 -0
  5. package/dist/delivery.js +1 -136
  6. package/dist/dev.js +9 -2
  7. package/dist/integrations.js +1 -1
  8. package/dist/model.js +128 -217
  9. package/dist/preview.js +1 -1
  10. package/dist/schema.d.ts +1 -0
  11. package/dist/schema.js +56 -0
  12. package/dist/{src-C6YqllXw.js → src-BMOqN7Xs.js} +3 -26
  13. package/dist/trace.js +1 -1
  14. package/dist/types/access/src/jwt.d.ts +6 -13
  15. package/dist/types/analytics/src/index.d.ts +2 -2
  16. package/dist/types/analytics/src/source.d.ts +0 -16
  17. package/dist/types/analytics/src/view.d.ts +24 -0
  18. package/dist/types/body/src/inline.d.ts +20 -0
  19. package/dist/types/body/src/normalize.d.ts +1 -3
  20. package/dist/types/cms-contract/src/index.d.ts +1 -1
  21. package/dist/types/cms-contract/src/roles.d.ts +3 -3
  22. package/dist/types/model/src/asset.d.ts +16 -0
  23. package/dist/types/model/src/index.d.ts +4 -3
  24. package/dist/types/model/src/mediaUrl.d.ts +2 -0
  25. package/dist/types/model/src/model.d.ts +1 -1
  26. package/dist/types/model/src/typesSource.d.ts +7 -0
  27. package/dist/types/{sdk/src/defaults.d.ts → platform/src/defaultModel.d.ts} +4 -1
  28. package/dist/types/sdk/src/analytics.d.ts +12 -2
  29. package/dist/types/sdk/src/delivery/index.d.ts +2 -2
  30. package/dist/types/sdk/src/delivery/values.d.ts +1 -17
  31. package/dist/types/sdk/src/model.d.ts +2 -2
  32. package/dist/types/sdk/src/schema.d.ts +5 -0
  33. package/dist/types/sdk/src/types-cli.d.ts +2 -0
  34. package/dist/types-cli.d.ts +1 -0
  35. package/dist/types-cli.js +7 -0
  36. package/dist/typesSource-BKPzvl--.js +62 -0
  37. package/package.json +8 -1
  38. package/dist/types/analytics/src/record.d.ts +0 -22
@@ -0,0 +1,20 @@
1
+ import type { Mark, TextStyle } from './types.js';
2
+ /** 装飾の順序(外側から内側、Markdown と HTML の入れ子の順) */
3
+ export declare const MARK_ORDER: readonly ["strong", "em", "strike", "underline", "mark", "sup", "sub", "code"];
4
+ /** 装飾を MARK_ORDER の順に並べる(重複は1つ) */
5
+ export declare const sortMarks: (marks: readonly Mark[] | undefined) => Mark[];
6
+ /** 装飾の描画の HTML の要素 */
7
+ export declare const MARK_HTML_TAGS: {
8
+ readonly strong: "strong";
9
+ readonly em: "em";
10
+ readonly code: "code";
11
+ readonly strike: "s";
12
+ readonly mark: "mark";
13
+ readonly sup: "sup";
14
+ readonly sub: "sub";
15
+ readonly underline: "u";
16
+ };
17
+ /** HTML の要素の装飾(描画の要素と、リッチエディタが使うほかの要素) */
18
+ export declare const HTML_TAG_MARKS: Readonly<Record<string, Mark>>;
19
+ /** 内側の見た目に外側の見た目を重ねる(内側を優先、名前のついた装飾は合わせる) */
20
+ export declare const mergeStyle: (outer: TextStyle | undefined, inner: TextStyle | undefined) => TextStyle | undefined;
@@ -1,6 +1,4 @@
1
- import { type Body, type Mark, type Rich } from './types.js';
2
- /** 装飾の順序(Markdown では外側から内側) */
3
- export declare const MARK_ORDER: readonly Mark[];
1
+ import { type Body, type Rich } from './types.js';
4
2
  /** インラインの断片の列を正規化 */
5
3
  export declare function normalizeRich(rich: Rich): Rich;
6
4
  /** 本文を正規化 */
@@ -9,7 +9,7 @@ export { type CallApi, type ConnectionPoint, type ContentTypePoint, createModule
9
9
  export { applyFieldRules, autoFieldsOf, type FieldRule, hiddenFieldsOf, restrictedChoicesOf, restrictedProblemsOf } from './fieldRules.js';
10
10
  export { pendingIds, pendingValue } from './pending.js';
11
11
  export { type AccountLink, type Action, ACTION_LEVELS, ACTIONS, allows, ANY_TARGET, canChangeRow, canDeleteContent, canEditContent, canPublishContent, canReadContent, canReadRow, canSubmitContent, checkPermissions, type ContentAccess, type Level, LEVELS, levelOf, ownsContent, ownsRow, type Permissions, type RowAccess } from './permissions.js';
12
- export { ADMIN_PERMISSIONS, ADMIN_ROLE, defaultRoleOf, isAdmin, rolePermissionsOf, type Role, SYSTEM_ROLES, type User, WRITER_ROLE } from './roles.js';
12
+ export { ADMIN_PERMISSIONS, ADMIN_ROLE, defaultRoleOf, isAdmin, rolePermissionsOf, type Role, SYSTEM_ROLES, type User, DEFAULT_ROLE } from './roles.js';
13
13
  export { isServerPath, OPS_PATHS, SERVER_PATHS } from './paths.js';
14
14
  export { CONFIG_FORMAT, type ConfigBundle, type ConfigPreview } from './transfer.js';
15
15
  export { IMPORT_ITEMS_MAX, IMPORT_PROBLEM_LABELS, IMPORT_PROBLEMS, type ImportIdChange, type ImportIdConflict, importIdOf, type ImportIdPlan, type ImportImage, type ImportItem, type ImportItemReport, type ImportProblem, type ImportProblemCode, type ImportReport, importReportOf, mergeImportReports, type MicroCmsApiInput, type MicroCmsContentResult, type MicroCmsDropped, type MicroCmsNote, planImportIds, sourceOf } from './import.js';
@@ -1,15 +1,15 @@
1
1
  import { type AccountLink, type Permissions } from './permissions.js';
2
2
  /** 管理者のロールの ID */
3
3
  export declare const ADMIN_ROLE = "admin";
4
- /** ライターのロールの ID(あれば新しいアカウントの既定、削除できる) */
5
- export declare const WRITER_ROLE = "writer";
4
+ /** 新しいアカウントの既定のロールの ID(テンプレートのロールの ID、あれば既定、削除できる) */
5
+ export declare const DEFAULT_ROLE = "writer";
6
6
  /** 管理者の権限の表(すべての対象・操作が可、DB の値より優先) */
7
7
  export declare const ADMIN_PERMISSIONS: Permissions;
8
8
  /** ロールの権限の表(管理者のロールは固定の表、ほかは保存した表) */
9
9
  export declare const rolePermissionsOf: (roleId: string, stored: Permissions) => Permissions;
10
10
  /** 削除できないロールの ID */
11
11
  export declare const SYSTEM_ROLES: readonly string[];
12
- /** 新しいアカウントの既定のロール(ライター、なければ管理者以外の最初のロール、それもなければ管理者) */
12
+ /** 新しいアカウントの既定のロール(DEFAULT_ROLE、なければ管理者以外の最初のロール、それもなければ管理者) */
13
13
  export declare const defaultRoleOf: (roles: readonly Pick<Role, "id">[]) => string;
14
14
  /** ロール(API /api/roles の行) */
15
15
  export type Role = Readonly<{
@@ -60,6 +60,22 @@ export type Asset = ImageAsset | VideoAsset | FileAsset;
60
60
  export type AssetRef = Readonly<{
61
61
  asset: string;
62
62
  }>;
63
+ /** 配信 API が解決した実体(url は配信 URL で配信のオリジンがある CMS だけ、hotspot・crop は元の画像に対する割合) */
64
+ export type DeliveredAsset = Readonly<{
65
+ id: string;
66
+ kind: 'image' | 'video' | 'file';
67
+ url?: string;
68
+ width: number;
69
+ height: number;
70
+ alt: string;
71
+ hotspot?: Hotspot;
72
+ crop?: Crop;
73
+ poster?: DeliveredAsset | null; /** 非公開の実体(url は署名のない配信 URL、signMediaUrl で署名して渡す) */
74
+ visibility?: 'private'; /** ファイルの元のファイル名・形式・大きさ(バイト) */
75
+ name?: string;
76
+ mimeType?: string;
77
+ size?: number;
78
+ }>;
63
79
  /**
64
80
  * 表示する素材の共通の項目
65
81
  * - src: URL(CMS の実体)か、ビルドで読み込んだ画像
@@ -1,14 +1,15 @@
1
1
  export { fieldZod, jsonSchemaOf, normalizeValues, zodOf, type ValueOptions } from './input.js';
2
- export { assetRefSchema, cropSchema, hotspotSchema, mediaSchema, type Asset, type AssetRef, type Crop, type Hotspot, type LocalImage, type Media } from './asset.js';
2
+ export { assetRefSchema, cropSchema, hotspotSchema, mediaSchema, type Asset, type AssetRef, type Crop, type DeliveredAsset, type Hotspot, type LocalImage, type Media } from './asset.js';
3
3
  export { coverPosition, coverStart, cropRect, croppedHotspot, objectPosition, stillOf, type CropRect } from './image.js';
4
4
  export { IMAGE_TYPE, VIDEO_TYPE } from './media.js';
5
- export { IMAGE_SIZE_MAX, imageParamsOf, MEDIA_SIGNING_KEY_BLOB, mediaBlobKeyOf, mediaExtOf, mediaKindOf, mediaMimeOf, mediaPathOf, parseMediaPath, signMediaUrl, verifyMediaUrl, withImageParams, type ImageParams, type AssetKind, type MediaPath } from './mediaUrl.js';
5
+ export { IMAGE_SIZE_MAX, imageParamsOf, isMediaId, MEDIA_SIGNING_KEY_BLOB, mediaBlobKeyOf, mediaExtOf, mediaKindOf, mediaMimeOf, mediaPathOf, parseMediaPath, signMediaUrl, verifyMediaUrl, withImageParams, type ImageParams, type AssetKind, type MediaPath } from './mediaUrl.js';
6
6
  export { diffSchema, renameType, type ChangeKind, type ChangeLevel, type DiffOptions, type SchemaChange } from './changes.js';
7
7
  export { dateRoleFieldsOf, primaryTypeOf, requiredPrimaryTypeOf, SOURCES_FIELD, sourceIdsOf, sourcesFieldOf, sourceTypeOf, type SourcesField } from './capabilities.js';
8
8
  export { appliesTo, checkFields, fieldsFor } from './check.js';
9
9
  export { deliveredFields, emptyValues, pickValues, referencedIds, referencesOf, valueFieldsOf } from './values.js';
10
+ export { typesSourceOf } from './typesSource.js';
10
11
  export { entryRefsOf, type EntryRef } from './refs.js';
11
- export { acceptsRole, bodyFieldsOf, computedFieldsOf, FIELD_ROLES, idInputOf, initialValueOf, isEditorial, isInputField, isListType, isMediaType, isSingleton, isStoredType, MEDIA_TYPE_IDS, optionLabelOf, optionsOf, publishingOf, requestReferencesOf, resolvedRolesOf, roleFieldOf, toneOf, typeOf, type ComputedKind, type FieldRole, type FieldRoles, type FieldComputed, type ContentFormat, type ContentModel, type ContentType, type FieldCondition, type FieldDef, type FieldDerive, type FieldFixedBy, type CountDef, type FieldProblem, type MediaKind, type OptionTone, type Publishing, type ReferenceRules, type SelectOption, usesReview } from './model.js';
12
+ export { acceptsRole, bodyFieldsOf, computedFieldsOf, FIELD_ROLES, idInputOf, initialValueOf, isPublishable, isInputField, isListType, isMediaType, isSingleton, isStoredType, MEDIA_TYPE_IDS, optionLabelOf, optionsOf, publishingOf, requestReferencesOf, resolvedRolesOf, roleFieldOf, toneOf, typeOf, type ComputedKind, type FieldRole, type FieldRoles, type FieldComputed, type ContentFormat, type ContentModel, type ContentType, type FieldCondition, type FieldDef, type FieldDerive, type FieldFixedBy, type CountDef, type FieldProblem, type MediaKind, type OptionTone, type Publishing, type ReferenceRules, type SelectOption, usesReview } from './model.js';
12
13
  export { hasPublicPage, imageFrameOf, pagePathOf, publicPathOf, withPagesFrom, type ImageFrame, type ImageFrameDef, type PageDef, type PageEntry, type PageRule } from './page.js';
13
14
  export { schemaRulesOf, type SchemaRule } from './rules.js';
14
15
  export { parseModel } from './schema.js';
@@ -16,6 +16,8 @@ export type MediaPath = Readonly<{
16
16
  width?: number;
17
17
  height?: number;
18
18
  }>;
19
+ /** 実体の ID の形か(CMS の /media と配信の Worker の共通、保存先のほかのキーを ID として読ませない) */
20
+ export declare const isMediaId: (id: string) => boolean;
19
21
  /** 配信 URL のパス(媒体・ID の形が不正、配信しない形式なら null) */
20
22
  export declare function mediaPathOf({ kind, project, id, mimeType, width, height }: Readonly<{
21
23
  kind: AssetKind;
@@ -183,7 +183,7 @@ export declare const isListType: (type: ContentType) => boolean;
183
183
  * - 機能: 版・楽観ロック・編集中のリース・コメント・公開の前の点検
184
184
  * - 提出と差し戻し・担当者: レビューありの型だけ(usesReview)
185
185
  */
186
- export declare const isEditorial: (type: ContentType) => boolean;
186
+ export declare const isPublishable: (type: ContentType) => boolean;
187
187
  /**
188
188
  * レビューのワークフローを持つ型か(レビューありの一覧の型)
189
189
  * - 機能: 提出と差し戻し・担当者(レビューを担当するアカウント)
@@ -0,0 +1,7 @@
1
+ import type { ContentModel } from './model.js';
2
+ /**
3
+ * スキーマから配信 API の値の型の定義(TypeScript のモジュールの文)
4
+ * - 型ごとに `export type <PascalCase の型の id>`、全体の対応 `CmsTypes` と型の id の一覧 `TYPE_IDS`
5
+ * - types: 配信する型だけ(メディアの型を除いた一覧、配信 API の `/types` の値)
6
+ */
7
+ export declare function typesSourceOf(model: Pick<ContentModel, 'types'>): string;
@@ -1,4 +1,7 @@
1
- import type { ContentModel, ScreenSettings } from '../../model/src/index.js';
1
+ import type { BodyProfile } from '../../body/src/index.js';
2
+ import { type ContentModel, type ScreenSettings } from '../../model/src/index.js';
3
+ /** 既定の本文の設定(本文の項目 profile と同じ値) */
4
+ export declare const DEFAULT_BODY_PROFILE: BodyProfile;
2
5
  /** 中立の既定のスキーマ(新しい媒体の作成で適用する型: post・author・tag・image・video、設定の移入の土台) */
3
6
  export declare const DEFAULT_SCHEMA: ContentModel;
4
7
  /** 既定の画面設定(新しい媒体の作成で適用する中立の値、移入する screens の土台) */
@@ -1,2 +1,12 @@
1
- export { recordView } from '../../analytics/src/index.js';
2
- export type { Classify, Dataset } from '../../analytics/src/index.js';
1
+ import { type Classify, type ViewOptions } from '../../analytics/src/index.js';
2
+ export type { Classify };
3
+ /** Analytics Engine のデータセットの binding(書き込みだけ) */
4
+ export type Dataset = {
5
+ writeDataPoint(point: {
6
+ blobs?: string[];
7
+ doubles?: number[];
8
+ indexes?: string[];
9
+ }): void;
10
+ };
11
+ /** 閲覧を1件記録(対象: GET で応答が200の HTML・ボット以外、binding なしと記録の失敗は無視) */
12
+ export declare function recordView(dataset: Dataset | undefined, request: Request, response: Response, options: ViewOptions): void;
@@ -2,8 +2,8 @@ export { cachedDelivery, memoryDeliveryCache, type DeliveryCache } from './cache
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
4
  export { deliveredImageUrl, mediaOf, type ImageUrl, type MediaOf } from './media.js';
5
- export { imageParamsOf, parseMediaPath, signMediaUrl, withImageParams, type ImageParams, type MediaPath } from '../../../model/src/index.js';
5
+ export { imageParamsOf, parseMediaPath, signMediaUrl, withImageParams, type DeliveredAsset, type ImageParams, type MediaPath } from '../../../model/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';
9
- export type { DeliveredAsset, FieldValue, Item, ItemMeta, ItemOf } from './values.js';
9
+ export type { FieldValue, Item, ItemMeta, ItemOf } from './values.js';
@@ -1,23 +1,7 @@
1
1
  import type { Body } from '../../../body/src/index.js';
2
- import type { ContentType, Crop, DateString, FieldDef, Hotspot } from '../../../model/src/index.js';
2
+ import type { ContentType, DateString, DeliveredAsset, FieldDef } from '../../../model/src/index.js';
3
3
  /** 配信 API の1件の値(id・項目の key・メタ情報 _meta) */
4
4
  export type Item = Readonly<Record<string, unknown>>;
5
- /** 配信 API が解決した実体(url は配信 URL で配信のオリジンがある CMS だけ、hotspot・crop は元の画像に対する割合) */
6
- export type DeliveredAsset = Readonly<{
7
- id: string;
8
- kind: 'image' | 'video' | 'file';
9
- url?: string;
10
- width: number;
11
- height: number;
12
- alt: string;
13
- hotspot?: Hotspot;
14
- crop?: Crop;
15
- poster?: DeliveredAsset | null; /** 非公開の実体(url は署名のない配信 URL、signMediaUrl で署名して渡す) */
16
- visibility?: 'private'; /** ファイルの元のファイル名・形式・大きさ(バイト) */
17
- name?: string;
18
- mimeType?: string;
19
- size?: number;
20
- }>;
21
5
  /** 項目の1つ分の値(複数の値を持つ項目は FieldValue が配列に、query.ts の絞り込みの値と共通) */
22
6
  export type SingleValue<F extends FieldDef> = F extends {
23
7
  type: 'text' | 'textarea';
@@ -1,5 +1,5 @@
1
- export { coverPosition, coverStart, createClock, cropRect, croppedHotspot, IMAGE_TYPE, isDateOnly, mediaSchema, objectPosition, pagePathOf, parseModel, parseScreens, publicPathOf, stillOf, typeOf, VIDEO_TYPE } from '../../model/src/index.js';
1
+ export { coverPosition, coverStart, createClock, cropRect, croppedHotspot, IMAGE_TYPE, isDateOnly, mediaSchema, objectPosition, pagePathOf, parseModel, parseScreens, publicPathOf, stillOf, typeOf, typesSourceOf, VIDEO_TYPE } from '../../model/src/index.js';
2
2
  export type { Asset, AssetRef, Clock, ContentModel, ContentType, Crop, CropRect, DateString, FieldDef, Hotspot, LocalImage, Media, PageDef, PageEntry, ScreenSettings } from '../../model/src/index.js';
3
3
  export { CONFIG_FORMAT } from '../../cms-contract/src/index.js';
4
4
  export type { ConfigBundle } from '../../cms-contract/src/index.js';
5
- export { DEFAULT_SCHEMA, DEFAULT_SCREENS } from './defaults.js';
5
+ export { DEFAULT_SCHEMA, DEFAULT_SCREENS } from '../../platform/src/defaultModel.js';
@@ -0,0 +1,5 @@
1
+ import { type ContentType } from '../../model/src/index.js';
2
+ /** 配信 API の型の一覧(/types、表示名・選択肢・上限・ページの URL の形を含む。実行時に読む値もここから) */
3
+ export declare function fetchDeliveredTypes(url: string, apiKey: string, fetcher?: typeof fetch): Promise<readonly ContentType[]>;
4
+ /** CLI の本体(戻り値は終了の状態) */
5
+ export declare function runTypesCli(argv: readonly string[], env: Readonly<Record<string, string | undefined>>, fetcher?: typeof fetch): Promise<number>;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from './types/sdk/src/types-cli.js';
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { runTypesCli } from "./schema.js";
3
+ // src/types-cli.ts
4
+ runTypesCli(process.argv.slice(2), process.env).then((code) => process.exit(code), (e) => {
5
+ console.error(e instanceof Error ? e.message : String(e));
6
+ process.exit(1);
7
+ });
@@ -0,0 +1,62 @@
1
+ // ../model/src/values.ts
2
+ /** 配信する項目(非公開の項目を除く、まとまりの中も) */
3
+ const deliveredFields = (fields) => fields.filter((f) => !f.private).map((f) => f.type === "group" ? {
4
+ ...f,
5
+ fields: deliveredFields(f.fields)
6
+ } : f);
7
+ // ../model/src/typesSource.ts
8
+ /** 生成した型の定義が SDK から読む型の import の元 */
9
+ const SDK = "@ryusenkei/maezae";
10
+ /** 型の import の行(指定は JSON の文字列の形) */
11
+ const importLine = (names, spec) => `import type { ${names.join(", ")} } from ${JSON.stringify(spec)};`;
12
+ const pascal = (id) => id.replace(/(^|[-_])(\w)/g, (_, __, ch) => ch.toUpperCase());
13
+ /** 項目の1つ分の値の型(SDK の SingleValue と同じ) */
14
+ function singleOf(f, indent) {
15
+ switch (f.type) {
16
+ case "text":
17
+ case "textarea":
18
+ case "datetime":
19
+ case "reference": return "string";
20
+ case "date": return "DateString";
21
+ case "number": return "number";
22
+ case "checkbox": return "boolean";
23
+ case "select": return f.options.map((o) => JSON.stringify(o.value)).join(" | ") || "string";
24
+ case "media": return "DeliveredAsset | null";
25
+ case "body": return "Body<DeliveredAsset | null>";
26
+ case "group": return `{\n${fieldsOf(deliveredFields(f.fields), `${indent} `)}\n${indent}}`;
27
+ }
28
+ }
29
+ /** 項目の値の型(SDK の FieldValue と同じ、複数は readonly の配列、値なしは null) */
30
+ const valueOf = (f, indent) => {
31
+ const one = singleOf(f, indent);
32
+ if ("multiple" in f && f.multiple) return `readonly ${one.includes(" | ") ? `(${one})` : one}[] | null`;
33
+ return one.endsWith(" | null") ? one : `${one} | null`;
34
+ };
35
+ /** 配信する項目の種類(まとまりの中を含む) */
36
+ const kindsOf = (fields) => deliveredFields(fields).flatMap((f) => [f.type, ...f.type === "group" ? kindsOf(f.fields) : []]);
37
+ const fieldsOf = (fields, indent) => fields.map((f) => `${indent}readonly ${f.key}: ${valueOf(f, indent)};`).join("\n");
38
+ const typeOf = (t) => `export type ${pascal(t.id)} = Readonly<{\n id: string;\n _meta: ItemMeta;\n${fieldsOf(deliveredFields(t.fields), " ")}\n}>;`;
39
+ /**
40
+ * スキーマから配信 API の値の型の定義(TypeScript のモジュールの文)
41
+ * - 型ごとに `export type <PascalCase の型の id>`、全体の対応 `CmsTypes` と型の id の一覧 `TYPE_IDS`
42
+ * - types: 配信する型だけ(メディアの型を除いた一覧、配信 API の `/types` の値)
43
+ */
44
+ function typesSourceOf(model) {
45
+ const types = [...model.types].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
46
+ const kinds = new Set(types.flatMap((t) => kindsOf(t.fields)));
47
+ const uses = (kind) => kinds.has(kind);
48
+ const delivery = ["ItemMeta", ...uses("media") || uses("body") ? ["DeliveredAsset"] : []].sort();
49
+ return [
50
+ "// Generated from the CMS schema (GET /content/v1/types). Do not edit; regenerate with maezae-types.",
51
+ importLine(delivery, `${SDK}/delivery`),
52
+ ...uses("body") ? [importLine(["Body"], `${SDK}/body`)] : [],
53
+ ...uses("date") ? [importLine(["DateString"], `${SDK}/model`)] : [],
54
+ "",
55
+ ...types.flatMap((t) => [typeOf(t), ""]),
56
+ `export type CmsTypes = {\n${types.map((t) => ` ${JSON.stringify(t.id)}: ${pascal(t.id)};`).join("\n")}\n};`,
57
+ "",
58
+ `export const TYPE_IDS = [${types.map((t) => JSON.stringify(t.id)).join(", ")}] as const;`,
59
+ ""
60
+ ].join("\n");
61
+ }
62
+ export { typesSourceOf as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryusenkei/maezae",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "maezae の導入先のサイト向けの SDK(配信 API の取得・本文の型・プレビューの署名・手元の開発の配信 API)",
5
5
  "license": "UNLICENSED",
6
6
  "author": "RYUSENKEI",
@@ -43,8 +43,15 @@
43
43
  "./dev": {
44
44
  "types": "./dist/dev.d.ts",
45
45
  "default": "./dist/dev.js"
46
+ },
47
+ "./schema": {
48
+ "types": "./dist/schema.d.ts",
49
+ "default": "./dist/schema.js"
46
50
  }
47
51
  },
52
+ "bin": {
53
+ "maezae-types": "./dist/types-cli.js"
54
+ },
48
55
  "files": [
49
56
  "dist"
50
57
  ],
@@ -1,22 +0,0 @@
1
- /** Analytics Engine のデータセットの binding(書き込みだけ) */
2
- export type Dataset = {
3
- writeDataPoint(point: {
4
- blobs?: string[];
5
- doubles?: number[];
6
- indexes?: string[];
7
- }): void;
8
- };
9
- /** パスから種類と ID への対応(利用側が定義、例: /articles/<id> は記事) */
10
- export type Classify = (path: string) => {
11
- kind: string;
12
- id: string;
13
- };
14
- /** 記録の設定(project は媒体の識別子) */
15
- type RecordOptions = {
16
- classify: Classify;
17
- timeZone: string;
18
- project?: string;
19
- };
20
- /** 閲覧を1件記録(対象: GET で応答が200の HTML・ボット以外、記録の失敗は無視) */
21
- export declare function recordView(dataset: Dataset | undefined, request: Request, response: Response, { classify, timeZone, project }: RecordOptions): void;
22
- export {};