@tbox.cn/app-module-activity-play 0.0.0-stage → 0.3.2

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 (49) hide show
  1. package/INTEGRATION.md +94 -0
  2. package/LICENSE +21 -0
  3. package/README.md +30 -2
  4. package/dist/chunk-CM4OEPC3.js +689 -0
  5. package/dist/chunk-HUBEOW44.js +98 -0
  6. package/dist/client/index.css +107 -0
  7. package/dist/client/index.d.ts +11 -0
  8. package/dist/client/index.js +6 -0
  9. package/dist/index.css +107 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +46 -0
  12. package/dist/server/index.d.ts +309 -0
  13. package/dist/server/index.js +42 -0
  14. package/package.json +67 -3
  15. package/skills/activity-play/SKILL.md +55 -0
  16. package/src/client/cards/activity-play/ActivityPlayCard.tsx +77 -0
  17. package/src/client/cards/activity-play/index.ts +1 -0
  18. package/src/client/cards/view.ts +42 -0
  19. package/src/client/index.ts +22 -0
  20. package/src/client/styles/activity-play.css +136 -0
  21. package/src/index.ts +6 -0
  22. package/src/server/cards/activity-play/meta.ts +26 -0
  23. package/src/server/cards/activity-play/samples.ts +116 -0
  24. package/src/server/cards/activity-play-prize-detail/meta.ts +29 -0
  25. package/src/server/cards/activity-play-prize-detail/samples.ts +54 -0
  26. package/src/server/cards/activity-play-prize-list/meta.ts +41 -0
  27. package/src/server/cards/activity-play-prize-list/samples.ts +78 -0
  28. package/src/server/cards/index.ts +7 -0
  29. package/src/server/errors.ts +101 -0
  30. package/src/server/index.ts +72 -0
  31. package/src/server/ports.ts +50 -0
  32. package/src/server/prizes/cards.ts +79 -0
  33. package/src/server/prizes/errors.ts +88 -0
  34. package/src/server/prizes/query.ts +101 -0
  35. package/src/server/prizes/subject.ts +29 -0
  36. package/src/server/query.ts +98 -0
  37. package/src/server/routes.ts +371 -0
  38. package/src/server/tools.ts +187 -0
  39. package/tbox.module.json +65 -0
  40. package/tests/cards-capture.test.ts +110 -0
  41. package/tests/entry.test.ts +458 -0
  42. package/tests/ports.test.ts +83 -0
  43. package/tests/prizes.test.ts +357 -0
  44. package/tests/routes.test.ts +271 -0
  45. package/tests/samples.test.ts +53 -0
  46. package/tests/smoke.test.ts +27 -0
  47. package/tests/tools.test.ts +251 -0
  48. package/tsconfig.json +8 -0
  49. package/tsup.config.ts +27 -0
@@ -0,0 +1,98 @@
1
+ // src/client/cards/view.ts
2
+ function activityPlayStatusText(status) {
3
+ switch (status) {
4
+ case "active":
5
+ return "\u8FDB\u884C\u4E2D";
6
+ case "not_started":
7
+ return "\u672A\u5F00\u59CB";
8
+ case "ended":
9
+ return "\u5DF2\u7ED3\u675F";
10
+ case "disabled":
11
+ return "\u5DF2\u4E0B\u7EBF";
12
+ default:
13
+ return status;
14
+ }
15
+ }
16
+ function activityPlayStatusTone(status) {
17
+ switch (status) {
18
+ case "active":
19
+ return "success";
20
+ case "not_started":
21
+ return "warning";
22
+ case "disabled":
23
+ return "muted";
24
+ default:
25
+ return "muted";
26
+ }
27
+ }
28
+ function formatActivityPlayTime(value) {
29
+ if (!value) return "";
30
+ const d = new Date(value);
31
+ if (Number.isNaN(d.getTime())) return value;
32
+ const pad = (n) => String(n).padStart(2, "0");
33
+ return `${d.getFullYear()}.${pad(d.getMonth() + 1)}.${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
34
+ }
35
+
36
+ // src/client/cards/activity-play/ActivityPlayCard.tsx
37
+ import { jsx, jsxs } from "react/jsx-runtime";
38
+ function ActivityRow({ item }) {
39
+ const tone = activityPlayStatusTone(item.status);
40
+ return /* @__PURE__ */ jsx("div", { className: "ap-card__row", children: /* @__PURE__ */ jsxs("div", { className: "ap-card__row-main", children: [
41
+ /* @__PURE__ */ jsxs("div", { className: "ap-card__row-title", children: [
42
+ /* @__PURE__ */ jsx("strong", { children: item.title }),
43
+ /* @__PURE__ */ jsx("span", { className: `ap-badge ap-badge--${tone}`, children: activityPlayStatusText(item.status) })
44
+ ] }),
45
+ item.description && /* @__PURE__ */ jsx("p", { className: "ap-card__row-desc", children: item.description })
46
+ ] }) });
47
+ }
48
+ function ActivityPlayCard(props) {
49
+ const { data } = props;
50
+ if (data.mode === "detail") {
51
+ const item = data.items[0];
52
+ if (!item) return null;
53
+ const range = [formatActivityPlayTime(item.startsAt), formatActivityPlayTime(item.endsAt)].filter(Boolean).join(" \u2014 ");
54
+ return /* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--detail", children: [
55
+ /* @__PURE__ */ jsx("span", { className: "ap-card__eyebrow", children: "\u6D3B\u52A8\u73A9\u6CD5" }),
56
+ /* @__PURE__ */ jsxs("div", { className: "ap-card__detail-head", children: [
57
+ /* @__PURE__ */ jsx("strong", { children: item.title }),
58
+ /* @__PURE__ */ jsx("span", { className: `ap-badge ap-badge--${activityPlayStatusTone(item.status)}`, children: activityPlayStatusText(item.status) })
59
+ ] }),
60
+ item.description && /* @__PURE__ */ jsx("p", { className: "ap-card__detail-desc", children: item.description }),
61
+ item.imageUrl && /* @__PURE__ */ jsx("img", { className: "ap-card__cover", src: item.imageUrl, alt: `${item.title}\u5C01\u9762`, loading: "lazy" }),
62
+ range && /* @__PURE__ */ jsxs("p", { className: "ap-card__meta", children: [
63
+ "\u6D3B\u52A8\u65F6\u95F4\uFF1A",
64
+ range
65
+ ] }),
66
+ item.loginRequired && /* @__PURE__ */ jsx("p", { className: "ap-card__meta", children: "\u53C2\u4E0E\u9700\u5148\u767B\u5F55" })
67
+ ] });
68
+ }
69
+ if (data.items.length === 0) {
70
+ return /* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--list", children: [
71
+ /* @__PURE__ */ jsx("span", { className: "ap-card__eyebrow", children: "\u6D3B\u52A8\u73A9\u6CD5" }),
72
+ /* @__PURE__ */ jsx("p", { className: "ap-card__empty", children: "\u5F53\u524D\u5546\u573A\u6682\u65E0\u8FDB\u884C\u4E2D\u7684\u6D3B\u52A8\u73A9\u6CD5" })
73
+ ] });
74
+ }
75
+ return /* @__PURE__ */ jsxs("section", { className: "ap-card ap-card--list", children: [
76
+ /* @__PURE__ */ jsxs("span", { className: "ap-card__eyebrow", children: [
77
+ "\u6D3B\u52A8\u73A9\u6CD5\uFF08",
78
+ data.items.length,
79
+ "\uFF09"
80
+ ] }),
81
+ /* @__PURE__ */ jsx("div", { className: "ap-card__list", children: data.items.map((item) => /* @__PURE__ */ jsx(ActivityRow, { item }, item.activityRef)) })
82
+ ] });
83
+ }
84
+
85
+ // src/client/index.ts
86
+ var cards = {
87
+ "activity-play": ActivityPlayCard
88
+ };
89
+ var clientModule = {
90
+ cards,
91
+ register(ctx) {
92
+ ctx.cards.registerMap(cards);
93
+ }
94
+ };
95
+
96
+ export {
97
+ clientModule
98
+ };
@@ -0,0 +1,107 @@
1
+ /* src/client/styles/activity-play.css */
2
+ .ap-card {
3
+ --ap-muted: var(--tbox-text-secondary, #8a8a8a);
4
+ --ap-faint: var(--tbox-text-muted, #b0b0b0);
5
+ --ap-border: var(--tbox-border-color, #ebebeb);
6
+ --ap-surface: var(--tbox-surface-subtle, #fafafa);
7
+ --ap-success: var(--tbox-success, #0f8a5f);
8
+ --ap-success-light: var(--tbox-success-light, #e6f7f0);
9
+ --ap-warning: var(--tbox-warning, #b26a00);
10
+ --ap-warning-light: var(--tbox-warning-light, #fff4e0);
11
+ }
12
+ .ap-card {
13
+ padding: 12px;
14
+ background: var(--ap-surface);
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: 10px;
18
+ }
19
+ .ap-card__eyebrow {
20
+ font-size: 12px;
21
+ line-height: 1;
22
+ color: var(--ap-faint);
23
+ letter-spacing: 1px;
24
+ }
25
+ .ap-badge {
26
+ flex: none;
27
+ font-size: 12px;
28
+ line-height: 18px;
29
+ padding: 0 6px;
30
+ border-radius: 9px;
31
+ }
32
+ .ap-badge--success {
33
+ color: var(--ap-success);
34
+ background: var(--ap-success-light);
35
+ }
36
+ .ap-badge--warning {
37
+ color: var(--ap-warning);
38
+ background: var(--ap-warning-light);
39
+ }
40
+ .ap-badge--muted {
41
+ color: var(--ap-muted);
42
+ background: rgba(0, 0, 0, 0.06);
43
+ }
44
+ .ap-card__list {
45
+ display: flex;
46
+ flex-direction: column;
47
+ }
48
+ .ap-card__row {
49
+ padding: 10px 0;
50
+ border-top: 1px solid var(--ap-border);
51
+ }
52
+ .ap-card__row:first-child {
53
+ border-top: none;
54
+ }
55
+ .ap-card__row-title {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 6px;
59
+ }
60
+ .ap-card__row-title strong {
61
+ font-size: 14px;
62
+ color: var(--tbox-text-primary, #303030);
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ }
67
+ .ap-card__row-desc {
68
+ margin-top: 4px;
69
+ font-size: 12px;
70
+ line-height: 18px;
71
+ color: var(--ap-muted);
72
+ display: -webkit-box;
73
+ -webkit-box-orient: vertical;
74
+ -webkit-line-clamp: 2;
75
+ overflow: hidden;
76
+ }
77
+ .ap-card__empty {
78
+ font-size: 13px;
79
+ line-height: 20px;
80
+ color: var(--ap-muted);
81
+ }
82
+ .ap-card--detail .ap-card__detail-head {
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 8px;
86
+ flex-wrap: wrap;
87
+ }
88
+ .ap-card--detail .ap-card__detail-head strong {
89
+ font-size: 16px;
90
+ color: var(--tbox-text-primary, #303030);
91
+ }
92
+ .ap-card--detail .ap-card__detail-desc {
93
+ font-size: 13px;
94
+ line-height: 20px;
95
+ color: var(--ap-muted);
96
+ }
97
+ .ap-card__cover {
98
+ width: 100%;
99
+ max-height: 180px;
100
+ object-fit: cover;
101
+ border-radius: 6px;
102
+ }
103
+ .ap-card__meta {
104
+ font-size: 12px;
105
+ line-height: 18px;
106
+ color: var(--ap-faint);
107
+ }
@@ -0,0 +1,11 @@
1
+ import { CardComponent } from '@tbox.cn/app-contracts';
2
+ import { ClientContext } from '@tbox.cn/app-agent-sdk-client';
3
+
4
+ declare const clientModule: {
5
+ cards: {
6
+ readonly 'activity-play': CardComponent;
7
+ };
8
+ register(ctx: ClientContext): void;
9
+ };
10
+
11
+ export { clientModule };
@@ -0,0 +1,6 @@
1
+ import {
2
+ clientModule
3
+ } from "../chunk-HUBEOW44.js";
4
+ export {
5
+ clientModule
6
+ };
package/dist/index.css ADDED
@@ -0,0 +1,107 @@
1
+ /* src/client/styles/activity-play.css */
2
+ .ap-card {
3
+ --ap-muted: var(--tbox-text-secondary, #8a8a8a);
4
+ --ap-faint: var(--tbox-text-muted, #b0b0b0);
5
+ --ap-border: var(--tbox-border-color, #ebebeb);
6
+ --ap-surface: var(--tbox-surface-subtle, #fafafa);
7
+ --ap-success: var(--tbox-success, #0f8a5f);
8
+ --ap-success-light: var(--tbox-success-light, #e6f7f0);
9
+ --ap-warning: var(--tbox-warning, #b26a00);
10
+ --ap-warning-light: var(--tbox-warning-light, #fff4e0);
11
+ }
12
+ .ap-card {
13
+ padding: 12px;
14
+ background: var(--ap-surface);
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: 10px;
18
+ }
19
+ .ap-card__eyebrow {
20
+ font-size: 12px;
21
+ line-height: 1;
22
+ color: var(--ap-faint);
23
+ letter-spacing: 1px;
24
+ }
25
+ .ap-badge {
26
+ flex: none;
27
+ font-size: 12px;
28
+ line-height: 18px;
29
+ padding: 0 6px;
30
+ border-radius: 9px;
31
+ }
32
+ .ap-badge--success {
33
+ color: var(--ap-success);
34
+ background: var(--ap-success-light);
35
+ }
36
+ .ap-badge--warning {
37
+ color: var(--ap-warning);
38
+ background: var(--ap-warning-light);
39
+ }
40
+ .ap-badge--muted {
41
+ color: var(--ap-muted);
42
+ background: rgba(0, 0, 0, 0.06);
43
+ }
44
+ .ap-card__list {
45
+ display: flex;
46
+ flex-direction: column;
47
+ }
48
+ .ap-card__row {
49
+ padding: 10px 0;
50
+ border-top: 1px solid var(--ap-border);
51
+ }
52
+ .ap-card__row:first-child {
53
+ border-top: none;
54
+ }
55
+ .ap-card__row-title {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 6px;
59
+ }
60
+ .ap-card__row-title strong {
61
+ font-size: 14px;
62
+ color: var(--tbox-text-primary, #303030);
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ }
67
+ .ap-card__row-desc {
68
+ margin-top: 4px;
69
+ font-size: 12px;
70
+ line-height: 18px;
71
+ color: var(--ap-muted);
72
+ display: -webkit-box;
73
+ -webkit-box-orient: vertical;
74
+ -webkit-line-clamp: 2;
75
+ overflow: hidden;
76
+ }
77
+ .ap-card__empty {
78
+ font-size: 13px;
79
+ line-height: 20px;
80
+ color: var(--ap-muted);
81
+ }
82
+ .ap-card--detail .ap-card__detail-head {
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 8px;
86
+ flex-wrap: wrap;
87
+ }
88
+ .ap-card--detail .ap-card__detail-head strong {
89
+ font-size: 16px;
90
+ color: var(--tbox-text-primary, #303030);
91
+ }
92
+ .ap-card--detail .ap-card__detail-desc {
93
+ font-size: 13px;
94
+ line-height: 20px;
95
+ color: var(--ap-muted);
96
+ }
97
+ .ap-card__cover {
98
+ width: 100%;
99
+ max-height: 180px;
100
+ object-fit: cover;
101
+ border-radius: 6px;
102
+ }
103
+ .ap-card__meta {
104
+ font-size: 12px;
105
+ line-height: 18px;
106
+ color: var(--ap-faint);
107
+ }
@@ -0,0 +1,10 @@
1
+ export { ACTIVITY_PLAY_CARD_TYPE, ACTIVITY_PLAY_LIMIT_DEFAULT, ACTIVITY_PLAY_LIMIT_MAX, ACTIVITY_PLAY_LIMIT_MIN, ActivityPlayErrorCode, ActivityPlayHttpError, activityMatchesForEntry, activityPlayCards, createActivityPlayRouter, createActivityPlayTools, normalizeActivityRef, normalizeKeyword, normalizeListLimit, queryActivityPlayDetail, queryActivityPlayList, requireMallIdOf, resolveActivityPlayEntryPort, resolveActivityPlayQueryPort, serverModule, toActivityPlayHttpError } from './server/index.js';
2
+ export { clientModule } from './client/index.js';
3
+ import '@tbox.cn/app-sdk-server';
4
+ import '@tbox.cn/app-contracts';
5
+ import 'zod';
6
+ import '@tbox.cn/app-agent-sdk-server';
7
+ import 'express';
8
+ import '@tbox.cn/app-contracts-mall';
9
+ import '@mastra/core/tools';
10
+ import '@tbox.cn/app-agent-sdk-client';
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import {
2
+ ACTIVITY_PLAY_CARD_TYPE,
3
+ ACTIVITY_PLAY_LIMIT_DEFAULT,
4
+ ACTIVITY_PLAY_LIMIT_MAX,
5
+ ACTIVITY_PLAY_LIMIT_MIN,
6
+ ActivityPlayHttpError,
7
+ activityMatchesForEntry,
8
+ activityPlayCards,
9
+ createActivityPlayRouter,
10
+ createActivityPlayTools,
11
+ normalizeActivityRef,
12
+ normalizeKeyword,
13
+ normalizeListLimit,
14
+ queryActivityPlayDetail,
15
+ queryActivityPlayList,
16
+ requireMallIdOf,
17
+ resolveActivityPlayEntryPort,
18
+ resolveActivityPlayQueryPort,
19
+ serverModule,
20
+ toActivityPlayHttpError
21
+ } from "./chunk-CM4OEPC3.js";
22
+ import {
23
+ clientModule
24
+ } from "./chunk-HUBEOW44.js";
25
+ export {
26
+ ACTIVITY_PLAY_CARD_TYPE,
27
+ ACTIVITY_PLAY_LIMIT_DEFAULT,
28
+ ACTIVITY_PLAY_LIMIT_MAX,
29
+ ACTIVITY_PLAY_LIMIT_MIN,
30
+ ActivityPlayHttpError,
31
+ activityMatchesForEntry,
32
+ activityPlayCards,
33
+ clientModule,
34
+ createActivityPlayRouter,
35
+ createActivityPlayTools,
36
+ normalizeActivityRef,
37
+ normalizeKeyword,
38
+ normalizeListLimit,
39
+ queryActivityPlayDetail,
40
+ queryActivityPlayList,
41
+ requireMallIdOf,
42
+ resolveActivityPlayEntryPort,
43
+ resolveActivityPlayQueryPort,
44
+ serverModule,
45
+ toActivityPlayHttpError
46
+ };