@ryusenkei/maezae 0.7.1 → 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.
- package/dist/analytics.js +3 -3
- package/dist/delivery.js +8 -8
- package/dist/types/analytics/src/index.d.ts +1 -1
- package/dist/types/analytics/src/record.d.ts +3 -3
- package/dist/types/analytics/src/source.d.ts +6 -6
- package/dist/types/cms-contract/src/embeds.d.ts +1 -1
- package/dist/types/model/src/mediaUrl.d.ts +3 -3
- package/dist/types/{delivery-client/src → sdk/src/delivery}/client.d.ts +6 -6
- package/dist/types/{delivery-client/src → sdk/src/delivery}/index.d.ts +1 -1
- package/dist/types/{delivery-client/src → sdk/src/delivery}/media.d.ts +1 -1
- package/dist/types/{delivery-client/src → sdk/src/delivery}/query.d.ts +1 -1
- package/dist/types/{delivery-client/src → sdk/src/delivery}/schema.d.ts +1 -1
- package/dist/types/{delivery-client/src → sdk/src/delivery}/values.d.ts +2 -2
- package/dist/types/sdk/src/delivery.d.ts +2 -2
- package/dist/types/sdk/src/dev.d.ts +1 -1
- package/package.json +1 -1
package/dist/analytics.js
CHANGED
|
@@ -11,7 +11,7 @@ const BOT = /bot|crawl|spider|slurp|preview|monitor|headless/i;
|
|
|
11
11
|
/** ボットの UA か */
|
|
12
12
|
const isBot = (userAgent) => BOT.test(userAgent ?? "");
|
|
13
13
|
/** 閲覧を1件記録(対象: GET で応答が200の HTML・ボット以外、記録の失敗は無視) */
|
|
14
|
-
function recordView(dataset, request, response, { classify, timeZone,
|
|
14
|
+
function recordView(dataset, request, response, { classify, timeZone, project }) {
|
|
15
15
|
if (!dataset || request.method !== "GET" || response.status !== 200) return;
|
|
16
16
|
if (!response.headers.get("content-type")?.includes("text/html") || isBot(request.headers.get("user-agent"))) return;
|
|
17
17
|
const path = new URL(request.url).pathname;
|
|
@@ -24,9 +24,9 @@ function recordView(dataset, request, response, { classify, timeZone, tenant })
|
|
|
24
24
|
path,
|
|
25
25
|
dayIn(timeZone),
|
|
26
26
|
"view",
|
|
27
|
-
|
|
27
|
+
project ?? ""
|
|
28
28
|
],
|
|
29
|
-
indexes: [
|
|
29
|
+
indexes: [project ?? kind]
|
|
30
30
|
});
|
|
31
31
|
} catch {}
|
|
32
32
|
}
|
package/dist/delivery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as croppedHotspot, d as createClock, i as typeOf, r as optionsOf, s as cropRect, t as pagePathOf } from "./page-TFUlKv3R.js";
|
|
2
|
-
//
|
|
2
|
+
// src/delivery/query.ts
|
|
3
3
|
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4
4
|
/** in の値の検査(コンマを含む値はクエリで区切れない) */
|
|
5
5
|
const joined = (values) => {
|
|
@@ -25,7 +25,7 @@ function listParams(query) {
|
|
|
25
25
|
if (query.cursor) params.cursor = query.cursor;
|
|
26
26
|
return params;
|
|
27
27
|
}
|
|
28
|
-
//
|
|
28
|
+
// src/delivery/client.ts
|
|
29
29
|
/** 配信 API のパスの前半 */
|
|
30
30
|
const DELIVERY_PATH = "/content/v1";
|
|
31
31
|
/** 配信 API の取得の失敗(call: 失敗した経路、status: 応答のステータス) */
|
|
@@ -134,10 +134,10 @@ const VIDEO_PATH = /^\/videos\/([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+)\.([a-z0-9]+)$/
|
|
|
134
134
|
function parseMediaPath(pathname) {
|
|
135
135
|
const image = IMAGE_PATH.exec(pathname);
|
|
136
136
|
if (image) {
|
|
137
|
-
const [,
|
|
137
|
+
const [, project, id, width, height, ext] = image;
|
|
138
138
|
return mediaMimeOf(ext)?.startsWith("image/") ? {
|
|
139
139
|
kind: "image",
|
|
140
|
-
|
|
140
|
+
project,
|
|
141
141
|
id,
|
|
142
142
|
ext,
|
|
143
143
|
width: Number(width),
|
|
@@ -146,10 +146,10 @@ function parseMediaPath(pathname) {
|
|
|
146
146
|
}
|
|
147
147
|
const video = VIDEO_PATH.exec(pathname);
|
|
148
148
|
if (video) {
|
|
149
|
-
const [,
|
|
149
|
+
const [, project, id, ext] = video;
|
|
150
150
|
return mediaMimeOf(ext)?.startsWith("video/") ? {
|
|
151
151
|
kind: "video",
|
|
152
|
-
|
|
152
|
+
project,
|
|
153
153
|
id,
|
|
154
154
|
ext
|
|
155
155
|
} : null;
|
|
@@ -224,7 +224,7 @@ function imageParamsOf(query) {
|
|
|
224
224
|
...rect && { rect }
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
//
|
|
227
|
+
// src/delivery/media.ts
|
|
228
228
|
/** 配信 URL の画像の切り抜き(クエリ rect、範囲なしは元の URL) */
|
|
229
229
|
const deliveredImageUrl = (src, rect) => rect ? withImageParams(src, { rect }) : src;
|
|
230
230
|
/**
|
|
@@ -274,7 +274,7 @@ function mediaOf(base, imageUrl) {
|
|
|
274
274
|
};
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
//
|
|
277
|
+
// src/delivery/schema.ts
|
|
278
278
|
/** 選択肢の項目から表示名の表(値 → 表示名、key はまとまりの中なら `links.kind` の形、選択肢の項目でなければ空) */
|
|
279
279
|
const optionLabels = (schema, type, key) => Object.fromEntries(optionsOf(typeOf(schema, type), key).map((o) => [o.value, o.label]));
|
|
280
280
|
/** 型の項目(なければ例外: 導入先の設定の誤り) */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { recordView, type Classify, type Dataset } from './record.js';
|
|
2
2
|
export { syncCron } from './schedule.js';
|
|
3
|
-
export { analyticsEngine, type DailyRow, fixedSource, type Source,
|
|
3
|
+
export { analyticsEngine, type DailyRow, fixedSource, type Source, projectDaily, type ProjectSource } from './source.js';
|
|
4
4
|
export { readDaily, syncDaily } from './store.js';
|
|
@@ -11,12 +11,12 @@ export type Classify = (path: string) => {
|
|
|
11
11
|
kind: string;
|
|
12
12
|
id: string;
|
|
13
13
|
};
|
|
14
|
-
/** 記録の設定(
|
|
14
|
+
/** 記録の設定(project は媒体の識別子) */
|
|
15
15
|
type RecordOptions = {
|
|
16
16
|
classify: Classify;
|
|
17
17
|
timeZone: string;
|
|
18
|
-
|
|
18
|
+
project?: string;
|
|
19
19
|
};
|
|
20
20
|
/** 閲覧を1件記録(対象: GET で応答が200の HTML・ボット以外、記録の失敗は無視) */
|
|
21
|
-
export declare function recordView(dataset: Dataset | undefined, request: Request, response: Response, { classify, timeZone,
|
|
21
|
+
export declare function recordView(dataset: Dataset | undefined, request: Request, response: Response, { classify, timeZone, project }: RecordOptions): void;
|
|
22
22
|
export {};
|
|
@@ -9,25 +9,25 @@ export type DailyRow = {
|
|
|
9
9
|
export type Source = {
|
|
10
10
|
daily(since: string): Promise<DailyRow[]>;
|
|
11
11
|
};
|
|
12
|
-
/** Analytics Engine の接続の設定(token は Account Analytics の読み取りの API トークン、
|
|
12
|
+
/** Analytics Engine の接続の設定(token は Account Analytics の読み取りの API トークン、project は絞り込む媒体の識別子) */
|
|
13
13
|
type AnalyticsEngineOptions = {
|
|
14
14
|
accountId: string;
|
|
15
15
|
token: string;
|
|
16
16
|
dataset: string;
|
|
17
|
-
|
|
17
|
+
project?: string;
|
|
18
18
|
};
|
|
19
19
|
/** 1回の問い合わせの行数 */
|
|
20
20
|
export declare const PAGE_ROWS = 10000;
|
|
21
21
|
/** 問い合わせの回数の上限(PAGE_ROWS との積が1回で集計できる行数) */
|
|
22
22
|
export declare const MAX_PAGES = 20;
|
|
23
23
|
/** Analytics Engine の SQL API の読み込み元 */
|
|
24
|
-
export declare function analyticsEngine({ accountId, token, dataset,
|
|
24
|
+
export declare function analyticsEngine({ accountId, token, dataset, project }: AnalyticsEngineOptions): Source;
|
|
25
25
|
/** 全媒体の読み込み元の型(since 以降の日付の閲覧数を媒体の識別子ごとに) */
|
|
26
|
-
export type
|
|
27
|
-
|
|
26
|
+
export type ProjectSource = {
|
|
27
|
+
dailyByProject(since: string): Promise<ReadonlyMap<string, DailyRow[]>>;
|
|
28
28
|
};
|
|
29
29
|
/** 全媒体を1回の問い合わせで集計する Analytics Engine の読み込み元(媒体の列が空の記録は除外) */
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function projectDaily(options: Omit<AnalyticsEngineOptions, 'project'>): ProjectSource;
|
|
31
31
|
/** 集計済みの行の読み込み元(定期の集計で全媒体の問い合わせ結果を媒体ごとに受け渡し、daily は since 以降の行) */
|
|
32
32
|
export declare const fixedSource: (rows: readonly DailyRow[]) => Source;
|
|
33
33
|
export {};
|
|
@@ -6,16 +6,16 @@ export declare const mediaMimeOf: (ext: string) => string | null;
|
|
|
6
6
|
/** 配信 URL のパスの要素(寸法は画像だけ) */
|
|
7
7
|
export type MediaPath = Readonly<{
|
|
8
8
|
kind: 'image' | 'video';
|
|
9
|
-
|
|
9
|
+
project: string;
|
|
10
10
|
id: string;
|
|
11
11
|
ext: string;
|
|
12
12
|
width?: number;
|
|
13
13
|
height?: number;
|
|
14
14
|
}>;
|
|
15
15
|
/** 配信 URL のパス(媒体・ID の形が不正、配信しない形式なら null) */
|
|
16
|
-
export declare function mediaPathOf({ kind,
|
|
16
|
+
export declare function mediaPathOf({ kind, project, id, mimeType, width, height }: Readonly<{
|
|
17
17
|
kind: 'image' | 'video';
|
|
18
|
-
|
|
18
|
+
project: string;
|
|
19
19
|
id: string;
|
|
20
20
|
mimeType: string;
|
|
21
21
|
width: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentType } from '
|
|
1
|
+
import type { ContentType } from '../../../model/src/index.js';
|
|
2
2
|
import { type ListQuery, type Page } from './query.js';
|
|
3
3
|
/** 配信 API のパスの前半 */
|
|
4
4
|
export declare const DELIVERY_PATH = "/content/v1";
|
|
@@ -43,11 +43,11 @@ export declare function createDeliveryClient(delivery: Delivery, { drafts, at }?
|
|
|
43
43
|
id: string;
|
|
44
44
|
label: string;
|
|
45
45
|
description?: string;
|
|
46
|
-
format?: import("
|
|
47
|
-
publishing?: import("
|
|
48
|
-
fields: readonly import("
|
|
49
|
-
pages?: readonly import("
|
|
50
|
-
counts?: readonly import("
|
|
46
|
+
format?: import("../../../model/src/model.js").ContentFormat;
|
|
47
|
+
publishing?: import("../../../model/src/model.js").Publishing;
|
|
48
|
+
fields: readonly import("../model.js").FieldDef[];
|
|
49
|
+
pages?: readonly import("../model.js").PageDef[];
|
|
50
|
+
counts?: readonly import("../../../model/src/model.js").CountDef[];
|
|
51
51
|
og?: string;
|
|
52
52
|
idInput?: boolean;
|
|
53
53
|
}>>(path: string, query: ListQuery<T> & Readonly<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createDeliveryClient, DELIVERY_PATH, DeliveryError, subPath, type BundleResult, type Delivery, type DeliveryClient, type Prefetched } from './client.js';
|
|
2
2
|
export { deliveredImageUrl, mediaOf, type ImageUrl, type MediaOf } from './media.js';
|
|
3
|
-
export { imageParamsOf, parseMediaPath, withImageParams, type ImageParams, type MediaPath } from '
|
|
3
|
+
export { imageParamsOf, parseMediaPath, withImageParams, type ImageParams, type MediaPath } from '../../../model/src/index.js';
|
|
4
4
|
export { listParams, type ListFilter, type ListQuery, type Page } from './query.js';
|
|
5
5
|
export { createDeliveryClock, fieldOf, limitOf, optionLabels, pagePath, type DeliveryClock } from './schema.js';
|
|
6
6
|
export type { DeliveredAsset, FieldValue, Item, ItemMeta, ItemOf } from './values.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CropRect, type Media } from '
|
|
1
|
+
import { type CropRect, type Media } from '../../../model/src/index.js';
|
|
2
2
|
/** 配信する画像の URL(元の URL と、元画像の画素での切り抜きの範囲から、配信の側で変換する URL) */
|
|
3
3
|
export type ImageUrl = (src: string, rect?: CropRect) => string;
|
|
4
4
|
/** 配信 URL の画像の切り抜き(クエリ rect、範囲なしは元の URL) */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Clock, type ContentModel, type DateString, type FieldDef, type PageEntry } from '
|
|
1
|
+
import { type Clock, type ContentModel, type DateString, type FieldDef, type PageEntry } from '../../../model/src/index.js';
|
|
2
2
|
/** 選択肢の項目から表示名の表(値 → 表示名、key はまとまりの中なら `links.kind` の形、選択肢の項目でなければ空) */
|
|
3
3
|
export declare const optionLabels: <K extends string = string>(schema: ContentModel, type: string, key: string) => Readonly<Record<K, string>>;
|
|
4
4
|
/** 型の項目(なければ例外: 導入先の設定の誤り) */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Body } from '
|
|
2
|
-
import type { ContentType, Crop, DateString, FieldDef, Hotspot } from '
|
|
1
|
+
import type { Body } from '../../../body/src/index.js';
|
|
2
|
+
import type { ContentType, Crop, DateString, FieldDef, Hotspot } from '../../../model/src/index.js';
|
|
3
3
|
/** 配信 API の1件の値(id・項目の key・メタ情報 _meta) */
|
|
4
4
|
export type Item = Readonly<Record<string, unknown>>;
|
|
5
5
|
/** 配信 API が解決した実体(url は配信 URL で配信のオリジンがある CMS だけ、hotspot・crop は元の画像に対する割合) */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createDeliveryClient, createDeliveryClock, deliveredImageUrl, DELIVERY_PATH, DeliveryError, fieldOf, imageParamsOf, limitOf, listParams, mediaOf, optionLabels, pagePath, parseMediaPath, subPath, withImageParams } from '
|
|
2
|
-
export type { BundleResult, DeliveredAsset, Delivery, DeliveryClient, DeliveryClock, FieldValue, ImageParams, ImageUrl, Item, ItemMeta, ItemOf, ListFilter, ListQuery, MediaOf, MediaPath, Page, Prefetched } from '
|
|
1
|
+
export { createDeliveryClient, createDeliveryClock, deliveredImageUrl, DELIVERY_PATH, DeliveryError, fieldOf, imageParamsOf, limitOf, listParams, mediaOf, optionLabels, pagePath, parseMediaPath, subPath, withImageParams } from './delivery/index.js';
|
|
2
|
+
export type { BundleResult, DeliveredAsset, Delivery, DeliveryClient, DeliveryClock, FieldValue, ImageParams, ImageUrl, Item, ItemMeta, ItemOf, ListFilter, ListQuery, MediaOf, MediaPath, Page, Prefetched } from './delivery/index.js';
|