@downcity/city 0.2.17 → 0.2.25

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 (164) hide show
  1. package/README.md +33 -16
  2. package/bin/city/admin/index.d.ts +36 -0
  3. package/bin/city/admin/index.d.ts.map +1 -0
  4. package/bin/city/admin/index.js +85 -0
  5. package/bin/city/admin/index.js.map +1 -0
  6. package/bin/city/admin/types.d.ts +41 -0
  7. package/bin/city/admin/types.d.ts.map +1 -0
  8. package/bin/city/admin/types.js +5 -0
  9. package/bin/city/admin/types.js.map +1 -0
  10. package/bin/city/city.d.ts +73 -0
  11. package/bin/city/city.d.ts.map +1 -0
  12. package/bin/city/city.js +116 -0
  13. package/bin/city/city.js.map +1 -0
  14. package/bin/city/http.d.ts +55 -0
  15. package/bin/city/http.d.ts.map +1 -0
  16. package/bin/city/http.js +78 -0
  17. package/bin/city/http.js.map +1 -0
  18. package/bin/city/index.d.ts +20 -0
  19. package/bin/city/index.d.ts.map +1 -0
  20. package/bin/city/index.js +14 -0
  21. package/bin/city/index.js.map +1 -0
  22. package/bin/city/invoker/ai/index.d.ts +126 -0
  23. package/bin/city/invoker/ai/index.d.ts.map +1 -0
  24. package/bin/city/invoker/ai/index.js +247 -0
  25. package/bin/city/invoker/ai/index.js.map +1 -0
  26. package/bin/city/invoker/ai/stream.d.ts +8 -0
  27. package/bin/city/invoker/ai/stream.d.ts.map +1 -0
  28. package/bin/city/invoker/ai/stream.js +17 -0
  29. package/bin/city/invoker/ai/stream.js.map +1 -0
  30. package/bin/city/invoker/ai/types.d.ts +14 -0
  31. package/bin/city/invoker/ai/types.d.ts.map +1 -0
  32. package/bin/city/invoker/ai/types.js +9 -0
  33. package/bin/city/invoker/ai/types.js.map +1 -0
  34. package/bin/city/invoker/balance/index.d.ts +76 -0
  35. package/bin/city/invoker/balance/index.d.ts.map +1 -0
  36. package/bin/city/invoker/balance/index.js +137 -0
  37. package/bin/city/invoker/balance/index.js.map +1 -0
  38. package/bin/city/invoker/balance/types.d.ts +324 -0
  39. package/bin/city/invoker/balance/types.d.ts.map +1 -0
  40. package/bin/city/invoker/balance/types.js +9 -0
  41. package/bin/city/invoker/balance/types.js.map +1 -0
  42. package/bin/city/invoker/env/index.d.ts +33 -0
  43. package/bin/city/invoker/env/index.d.ts.map +1 -0
  44. package/bin/city/invoker/env/index.js +53 -0
  45. package/bin/city/invoker/env/index.js.map +1 -0
  46. package/bin/city/invoker/env/types.d.ts +57 -0
  47. package/bin/city/invoker/env/types.d.ts.map +1 -0
  48. package/bin/city/invoker/env/types.js +5 -0
  49. package/bin/city/invoker/env/types.js.map +1 -0
  50. package/bin/city/invoker/invoker.d.ts +44 -0
  51. package/bin/city/invoker/invoker.d.ts.map +1 -0
  52. package/bin/city/invoker/invoker.js +87 -0
  53. package/bin/city/invoker/invoker.js.map +1 -0
  54. package/bin/city/invoker/payment/index.d.ts +69 -0
  55. package/bin/city/invoker/payment/index.d.ts.map +1 -0
  56. package/bin/city/invoker/payment/index.js +110 -0
  57. package/bin/city/invoker/payment/index.js.map +1 -0
  58. package/bin/city/invoker/payment/types.d.ts +66 -0
  59. package/bin/city/invoker/payment/types.d.ts.map +1 -0
  60. package/bin/city/invoker/payment/types.js +10 -0
  61. package/bin/city/invoker/payment/types.js.map +1 -0
  62. package/bin/city/invoker/towns/index.d.ts +46 -0
  63. package/bin/city/invoker/towns/index.d.ts.map +1 -0
  64. package/bin/city/invoker/towns/index.js +73 -0
  65. package/bin/city/invoker/towns/index.js.map +1 -0
  66. package/bin/city/invoker/towns/types.d.ts +46 -0
  67. package/bin/city/invoker/towns/types.d.ts.map +1 -0
  68. package/bin/city/invoker/towns/types.js +5 -0
  69. package/bin/city/invoker/towns/types.js.map +1 -0
  70. package/bin/city/types/city.d.ts +71 -0
  71. package/bin/city/types/city.d.ts.map +1 -0
  72. package/bin/city/types/city.js +8 -0
  73. package/bin/city/types/city.js.map +1 -0
  74. package/bin/city/user/index.d.ts +27 -0
  75. package/bin/city/user/index.d.ts.map +1 -0
  76. package/bin/city/user/index.js +100 -0
  77. package/bin/city/user/index.js.map +1 -0
  78. package/bin/city/user/types.d.ts +49 -0
  79. package/bin/city/user/types.d.ts.map +1 -0
  80. package/bin/city/user/types.js +5 -0
  81. package/bin/city/user/types.js.map +1 -0
  82. package/bin/core/auth/authenticator.d.ts +6 -6
  83. package/bin/core/auth/authenticator.d.ts.map +1 -1
  84. package/bin/core/auth/authenticator.js +11 -11
  85. package/bin/core/auth/authenticator.js.map +1 -1
  86. package/bin/core/auth/token-signer.js +4 -4
  87. package/bin/core/auth/token-signer.js.map +1 -1
  88. package/bin/core/auth/types.d.ts +7 -7
  89. package/bin/core/auth/types.d.ts.map +1 -1
  90. package/bin/core/base/base-init.d.ts +5 -5
  91. package/bin/core/base/base-init.d.ts.map +1 -1
  92. package/bin/core/base/base-init.js +8 -8
  93. package/bin/core/base/base-init.js.map +1 -1
  94. package/bin/core/base/base-instruction.js +1 -1
  95. package/bin/core/base/base-instruction.js.map +1 -1
  96. package/bin/core/base/base-router.d.ts +2 -2
  97. package/bin/core/base/base-router.d.ts.map +1 -1
  98. package/bin/core/base/base-router.js +15 -15
  99. package/bin/core/base/base-router.js.map +1 -1
  100. package/bin/core/base/base-runtime.d.ts +3 -3
  101. package/bin/core/base/base-runtime.d.ts.map +1 -1
  102. package/bin/core/base/base-runtime.js +4 -4
  103. package/bin/core/base/base-runtime.js.map +1 -1
  104. package/bin/core/base/base.d.ts +8 -8
  105. package/bin/core/base/base.d.ts.map +1 -1
  106. package/bin/core/base/base.js +10 -10
  107. package/bin/core/base/base.js.map +1 -1
  108. package/bin/core/runtime.d.ts +4 -4
  109. package/bin/core/runtime.d.ts.map +1 -1
  110. package/bin/core/runtime.js +1 -1
  111. package/bin/core/types.d.ts +3 -3
  112. package/bin/core/types.d.ts.map +1 -1
  113. package/bin/index.d.ts +25 -5
  114. package/bin/index.d.ts.map +1 -1
  115. package/bin/index.js +18 -7
  116. package/bin/index.js.map +1 -1
  117. package/bin/service/ai/openai-compatible-provider.d.ts +1 -1
  118. package/bin/service/ai/openai-compatible-provider.js +2 -2
  119. package/bin/service/ai/openai-compatible-provider.js.map +1 -1
  120. package/bin/service/ai/provider.d.ts +1 -1
  121. package/bin/service/ai/provider.js +1 -1
  122. package/bin/service/ai/types.d.ts +1 -1
  123. package/bin/service/installable-service.d.ts +3 -3
  124. package/bin/service/installable-service.d.ts.map +1 -1
  125. package/bin/service/installable-service.js +1 -1
  126. package/bin/service/installable-service.js.map +1 -1
  127. package/bin/service/instruction.js +7 -7
  128. package/bin/service/instruction.js.map +1 -1
  129. package/bin/service/service.d.ts +5 -5
  130. package/bin/service/service.d.ts.map +1 -1
  131. package/bin/service/service.js +1 -1
  132. package/bin/service/service.js.map +1 -1
  133. package/bin/service/{studios → towns}/schema.d.ts +23 -23
  134. package/bin/service/towns/schema.d.ts.map +1 -0
  135. package/bin/service/towns/schema.js +60 -0
  136. package/bin/service/towns/schema.js.map +1 -0
  137. package/bin/service/towns/town-store.d.ts +17 -0
  138. package/bin/service/towns/town-store.d.ts.map +1 -0
  139. package/bin/service/towns/town-store.js +49 -0
  140. package/bin/service/towns/town-store.js.map +1 -0
  141. package/bin/service/towns/towns-service.d.ts +15 -0
  142. package/bin/service/towns/towns-service.d.ts.map +1 -0
  143. package/bin/service/towns/towns-service.js +54 -0
  144. package/bin/service/towns/towns-service.js.map +1 -0
  145. package/bin/service/towns/types.d.ts +51 -0
  146. package/bin/service/towns/types.d.ts.map +1 -0
  147. package/bin/service/towns/types.js +7 -0
  148. package/bin/service/towns/types.js.map +1 -0
  149. package/package.json +9 -8
  150. package/bin/service/studios/schema.d.ts.map +0 -1
  151. package/bin/service/studios/schema.js +0 -60
  152. package/bin/service/studios/schema.js.map +0 -1
  153. package/bin/service/studios/studio-store.d.ts +0 -17
  154. package/bin/service/studios/studio-store.d.ts.map +0 -1
  155. package/bin/service/studios/studio-store.js +0 -49
  156. package/bin/service/studios/studio-store.js.map +0 -1
  157. package/bin/service/studios/studios-service.d.ts +0 -15
  158. package/bin/service/studios/studios-service.d.ts.map +0 -1
  159. package/bin/service/studios/studios-service.js +0 -51
  160. package/bin/service/studios/studios-service.js.map +0 -1
  161. package/bin/service/studios/types.d.ts +0 -51
  162. package/bin/service/studios/types.d.ts.map +0 -1
  163. package/bin/service/studios/types.js +0 -7
  164. package/bin/service/studios/types.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Town 层公共类型。
3
+ *
4
+ * Town 是 City 多租户隔离的基本单位,每个 API 调用都绑定到一个 Town。
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/service/towns/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@downcity/city",
3
- "version": "0.2.17",
4
- "description": "Downcity City runtime foundation for services, actions, auth, env, and studio-scoped gates.",
3
+ "version": "0.2.25",
4
+ "description": "Downcity City runtime and City access SDK for services, actions, auth, env, and towns.",
5
5
  "type": "module",
6
6
  "main": "./bin/index.js",
7
7
  "module": "./bin/index.js",
@@ -36,17 +36,18 @@
36
36
  ],
37
37
  "license": "MIT",
38
38
  "devDependencies": {
39
- "@types/better-sqlite3": "^7.6.0",
40
- "better-sqlite3": "^12.0.0",
41
- "typescript": "^5.7.0"
39
+ "@types/better-sqlite3": "^7.6.13",
40
+ "better-sqlite3": "^12.10.0",
41
+ "typescript": "^6.0.3"
42
42
  },
43
43
  "dependencies": {
44
- "ai": "^6.0.168",
44
+ "ai": "^6.0.193",
45
45
  "drizzle-orm": "^0.45.2",
46
- "hono": "^4.1.0"
46
+ "hono": "^4.12.23",
47
+ "@downcity/type": "0.1.6"
47
48
  },
48
49
  "scripts": {
49
- "build": "tsc",
50
+ "build": "rm -rf bin tsconfig.tsbuildinfo && tsc",
50
51
  "dev": "tsc --watch",
51
52
  "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
52
53
  "test": "tsc && tsc -p tsconfig.test.json && node --test test/*.test.mjs",
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/service/studios/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBpB,CAAC"}
@@ -1,60 +0,0 @@
1
- /**
2
- * Studio 数据库 schema 模块。
3
- *
4
- * 定义 Downcity 内置的 Studio 表结构(SQLite + Postgres)。
5
- * Studio 是 City 多租户隔离的基本单位。
6
- */
7
- import { pgTable, text as pgText } from "drizzle-orm/pg-core";
8
- import { sqliteTable, text as sqliteText } from "drizzle-orm/sqlite-core";
9
- const DEFAULT_STUDIO_TABLE = "studios";
10
- /**
11
- * 默认 SQLite Studio 表。
12
- */
13
- export const sqliteStudios = sqliteTable(DEFAULT_STUDIO_TABLE, {
14
- /**
15
- * Studio ID。
16
- */
17
- studio_id: sqliteText("studio_id").primaryKey(),
18
- /**
19
- * Studio 名称。
20
- */
21
- name: sqliteText("name").notNull(),
22
- /**
23
- * Studio 状态。
24
- */
25
- status: sqliteText("status").notNull(),
26
- /**
27
- * Studio 创建时间。
28
- */
29
- created_at: sqliteText("created_at").notNull(),
30
- /**
31
- * Studio 更新时间。
32
- */
33
- updated_at: sqliteText("updated_at").notNull(),
34
- });
35
- /**
36
- * 默认 Postgres Studio 表。
37
- */
38
- export const pgStudios = pgTable(DEFAULT_STUDIO_TABLE, {
39
- /**
40
- * Studio ID。
41
- */
42
- studio_id: pgText("studio_id").primaryKey(),
43
- /**
44
- * Studio 名称。
45
- */
46
- name: pgText("name").notNull(),
47
- /**
48
- * Studio 状态。
49
- */
50
- status: pgText("status").notNull(),
51
- /**
52
- * Studio 创建时间。
53
- */
54
- created_at: pgText("created_at").notNull(),
55
- /**
56
- * Studio 更新时间。
57
- */
58
- updated_at: pgText("updated_at").notNull(),
59
- });
60
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/service/studios/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,oBAAoB,EAAE;IAC7D;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE;IAE/C;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAElC;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAEtC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAE9C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;CAC/C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,oBAAoB,EAAE;IACrD;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE;IAE3C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAE9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;IAElC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAE1C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;CAC3C,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Studio 数据存储。
3
- *
4
- * 基于 CityTableApi,不直接依赖 Drizzle。
5
- */
6
- import type { CityTableApi } from "../../store/table-api.js";
7
- import type { Studio, StudioCreateInput, StudioStatus } from "./types.js";
8
- export declare class StudioStore {
9
- private table;
10
- constructor(table: CityTableApi<Studio>);
11
- list(): Promise<Studio[]>;
12
- get(studio_id: string): Promise<Studio | undefined>;
13
- create(input: StudioCreateInput): Promise<Studio>;
14
- setStatus(studio_id: string, status: StudioStatus): Promise<Studio>;
15
- remove(studio_id: string): Promise<void>;
16
- }
17
- //# sourceMappingURL=studio-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"studio-store.d.ts","sourceRoot":"","sources":["../../../src/service/studios/studio-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,qBAAa,WAAW;IACV,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;IAEzC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKnD,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAejD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAWnE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Studio 数据存储。
3
- *
4
- * 基于 CityTableApi,不直接依赖 Drizzle。
5
- */
6
- import { randomSecret } from "../../utils/helpers.js";
7
- export class StudioStore {
8
- table;
9
- constructor(table) {
10
- this.table = table;
11
- }
12
- async list() {
13
- return this.table.select();
14
- }
15
- async get(studio_id) {
16
- const rows = await this.table.select({ studio_id });
17
- return rows[0];
18
- }
19
- async create(input) {
20
- const name = String(input.name ?? "").trim();
21
- if (!name)
22
- throw new TypeError("Studio name is required");
23
- const now = new Date().toISOString();
24
- const studio = {
25
- studio_id: input.studio_id ?? `studio_${randomSecret(12)}`,
26
- name,
27
- status: "active",
28
- created_at: now,
29
- updated_at: now,
30
- };
31
- await this.table.insert(studio);
32
- return studio;
33
- }
34
- async setStatus(studio_id, status) {
35
- if (status !== "active" && status !== "paused") {
36
- throw new TypeError(`Invalid studio status: ${String(status)}`);
37
- }
38
- const existing = await this.get(studio_id);
39
- if (!existing)
40
- throw new Error(`Unknown studio: ${studio_id}`);
41
- const next = { ...existing, status, updated_at: new Date().toISOString() };
42
- await this.table.update({ where: { studio_id }, values: next });
43
- return next;
44
- }
45
- async remove(studio_id) {
46
- await this.table.delete({ studio_id });
47
- }
48
- }
49
- //# sourceMappingURL=studio-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"studio-store.js","sourceRoot":"","sources":["../../../src/service/studios/studio-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD,MAAM,OAAO,WAAW;IACF;IAApB,YAAoB,KAA2B;QAA3B,UAAK,GAAL,KAAK,CAAsB;IAAG,CAAC;IAEnD,KAAK,CAAC,IAAI;Q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,GAAG,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;QACnF,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAqB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,EAAqB,CAAC,CAAC;IAC5D,CAAC;CACF"}
@@ -1,15 +0,0 @@
1
- /**
2
- * studios 内置服务。
3
- *
4
- * 关键说明(中文)
5
- * - City 默认注册该 service。
6
- * - StudioStore 由 City 初始化并注入,确保鉴权和管理 API 使用同一份 studio 状态。
7
- */
8
- import { Service } from "../service.js";
9
- export declare class StudiosService extends Service {
10
- private store;
11
- private auth;
12
- constructor();
13
- _onInit(): Promise<void>;
14
- }
15
- //# sourceMappingURL=studios-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"studios-service.d.ts","sourceRoot":"","sources":["../../../src/service/studios/studios-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,qBAAa,cAAe,SAAQ,OAAO;IACzC,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,IAAI,CAAiB;;IAuCvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAS/B"}
@@ -1,51 +0,0 @@
1
- /**
2
- * studios 内置服务。
3
- *
4
- * 关键说明(中文)
5
- * - City 默认注册该 service。
6
- * - StudioStore 由 City 初始化并注入,确保鉴权和管理 API 使用同一份 studio 状态。
7
- */
8
- import { Service } from "../service.js";
9
- export class StudiosService extends Service {
10
- store;
11
- auth;
12
- constructor() {
13
- super({ id: "studios", name: "Studios" });
14
- this.instruction = [
15
- "管理 City 中的 studio 实体与用户 token 签发。",
16
- "studio 是用户侧调用的边界,user_token 会绑定到具体 studio。",
17
- "管理端通常先创建 studio,再通过 tokens/apply 为某个 user_id 签发可调用的 user_token。",
18
- ].join("\n");
19
- this.action("list", async () => ({ items: await this.store.list() }), { method: "GET", auth: ["admin"] });
20
- this.action("create", async (ctx) => {
21
- return await this.store.create({ name: String(ctx.input.name ?? "") });
22
- }, { auth: ["admin"] });
23
- this.action("pause", async (ctx) => {
24
- return await this.store.setStatus(String(ctx.input.studio_id ?? ""), "paused");
25
- }, { auth: ["admin"] });
26
- this.action("activate", async (ctx) => {
27
- return await this.store.setStatus(String(ctx.input.studio_id ?? ""), "active");
28
- }, { auth: ["admin"] });
29
- this.action("remove", async (ctx) => {
30
- await this.store.remove(String(ctx.input.studio_id ?? ""));
31
- return { success: true };
32
- }, { auth: ["admin"] });
33
- this.action("tokens/apply", async (ctx) => {
34
- return await this.auth.createToken({
35
- studio_id: String(ctx.input.studio_id ?? ""),
36
- user_id: String(ctx.input.user_id ?? ""),
37
- metadata: ctx.input.metadata,
38
- ttl: ctx.input.ttl,
39
- });
40
- }, { auth: ["admin"] });
41
- }
42
- async _onInit() {
43
- this.store = this._studioStore;
44
- this.auth = this._authenticator;
45
- const existing = await this.store.get("studio_downcity");
46
- if (!existing) {
47
- await this.store.create({ studio_id: "studio_downcity", name: "Downcity" });
48
- }
49
- }
50
- }
51
- //# sourceMappingURL=studios-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"studios-service.js","sourceRoot":"","sources":["../../../src/service/studios/studios-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,MAAM,OAAO,cAAe,SAAQ,OAAO;IACjC,KAAK,CAAe;IACpB,IAAI,CAAiB;IAE7B;QACE,KAAK,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1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- *
4
- * Studio 是 City 多租户隔离的基本单位,每个 API 调用都绑定到一个 Studio。
5
- */
6
- /**
7
- * Studio 当前状态。
8
- */
9
- export type StudioStatus = "active" | "paused";
10
- /**
11
- * City 中的 Studio 记录。
12
- */
13
- export interface Studio extends Record<string, unknown> {
14
- /**
15
- * Studio 的唯一 ID。
16
- */
17
- studio_id: string;
18
- /**
19
- * Studio 展示名称。
20
- */
21
- name: string;
22
- /**
23
- * Studio 当前状态。
24
- */
25
- status: StudioStatus;
26
- /**
27
- * Studio 创建时间。
28
- */
29
- created_at: string;
30
- /**
31
- * Studio 最后更新时间。
32
- */
33
- updated_at: string;
34
- }
35
- /**
36
- * 创建 Studio 时的输入。
37
- */
38
- export interface StudioCreateInput {
39
- /**
40
- * Studio 展示名称。
41
- */
42
- name: string;
43
- /**
44
- * 自定义 Studio ID。
45
- *
46
- * 未传入时由 City 自动生成 `studio_${randomSecret(12)}` 格式的 ID。
47
- * 传入时直接采用该值,便于在种子场景中使用固定 ID。
48
- */
49
- studio_id?: string;
50
- }
51
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/service/studios/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACrD;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Studio 层公共类型。
3
- *
4
- * Studio 是 City 多租户隔离的基本单位,每个 API 调用都绑定到一个 Studio。
5
- */
6
- export {};
7
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/service/studios/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}