@agentgo-tw/app-sdk 0.0.0-stage → 2.6.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/README.md +552 -2
- package/dist/browser.cjs +335 -0
- package/dist/browser.d.cts +22 -0
- package/dist/browser.d.ts +22 -0
- package/dist/browser.js +66 -0
- package/dist/chunk-4KBWZDXW.js +208 -0
- package/dist/chunk-VCZOS6GJ.js +61 -0
- package/dist/client.cjs +283 -0
- package/dist/client.d.cts +76 -0
- package/dist/client.d.ts +76 -0
- package/dist/client.js +205 -0
- package/dist/index.cjs +634 -0
- package/dist/index.d.cts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +364 -0
- package/dist/od-BVdmZf1t.d.cts +2331 -0
- package/dist/od-sGQixHat.d.ts +2331 -0
- package/dist/version-ClrVQNzw.d.cts +214 -0
- package/dist/version-ClrVQNzw.d.ts +214 -0
- package/package.json +67 -4
package/dist/browser.cjs
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/browser.ts
|
|
21
|
+
var browser_exports = {};
|
|
22
|
+
__export(browser_exports, {
|
|
23
|
+
AcademyError: () => AcademyError,
|
|
24
|
+
CONTRACT_VERSION: () => CONTRACT_VERSION,
|
|
25
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
26
|
+
academyBrowser: () => academyBrowser
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(browser_exports);
|
|
29
|
+
|
|
30
|
+
// src/errors.ts
|
|
31
|
+
var AcademyError = class extends Error {
|
|
32
|
+
code;
|
|
33
|
+
status;
|
|
34
|
+
details;
|
|
35
|
+
constructor(code, message, status = 0, details = {}) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = "AcademyError";
|
|
38
|
+
this.code = code;
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.details = details;
|
|
41
|
+
}
|
|
42
|
+
/** `LOGIN_REQUIRED` 的重新登入網址 */
|
|
43
|
+
get loginUrl() {
|
|
44
|
+
return str(this.details.login_url);
|
|
45
|
+
}
|
|
46
|
+
/** `SUBSCRIPTION_REQUIRED` 的訂閱網址 */
|
|
47
|
+
get subscribeUrl() {
|
|
48
|
+
return str(this.details.subscribe_url);
|
|
49
|
+
}
|
|
50
|
+
/** `INSUFFICIENT_POINTS` 的升級網址 */
|
|
51
|
+
get upgradeUrl() {
|
|
52
|
+
return str(this.details.upgrade_url);
|
|
53
|
+
}
|
|
54
|
+
/** 429 類錯誤建議等待的秒數 */
|
|
55
|
+
get retryAfterSeconds() {
|
|
56
|
+
const v = this.details.retry_after_seconds;
|
|
57
|
+
return typeof v === "number" ? v : void 0;
|
|
58
|
+
}
|
|
59
|
+
/** `AI_LIMIT_EXCEEDED`/`DATA_UNAVAILABLE` 的原因 */
|
|
60
|
+
get reason() {
|
|
61
|
+
return str(this.details.reason);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var str = (v) => typeof v === "string" ? v : void 0;
|
|
65
|
+
async function errorFromResponse(res) {
|
|
66
|
+
let body = {};
|
|
67
|
+
try {
|
|
68
|
+
body = await res.json();
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
const { code, message, ...rest } = body;
|
|
72
|
+
const fallback = res.status === 401 ? "IDENTITY_EXPIRED" : res.status === 402 ? "INSUFFICIENT_POINTS" : res.status >= 500 ? "AI_UNAVAILABLE" : "INVALID_REQUEST";
|
|
73
|
+
return new AcademyError(
|
|
74
|
+
typeof code === "string" && code ? code : fallback,
|
|
75
|
+
typeof message === "string" && message ? message : `\u5E73\u53F0\u56DE\u61C9 HTTP ${res.status}`,
|
|
76
|
+
res.status,
|
|
77
|
+
rest
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/sse.ts
|
|
82
|
+
async function* parseSse(body, onError) {
|
|
83
|
+
const reader = body.getReader();
|
|
84
|
+
const decoder = new TextDecoder();
|
|
85
|
+
let buf = "";
|
|
86
|
+
try {
|
|
87
|
+
for (; ; ) {
|
|
88
|
+
const { done, value } = await reader.read();
|
|
89
|
+
if (done) break;
|
|
90
|
+
buf += decoder.decode(value, { stream: true });
|
|
91
|
+
let idx;
|
|
92
|
+
while ((idx = buf.search(/\r?\n\r?\n/)) >= 0) {
|
|
93
|
+
const event = buf.slice(0, idx);
|
|
94
|
+
buf = buf.slice(idx).replace(/^\r?\n\r?\n/, "");
|
|
95
|
+
const data = event.split(/\r?\n/).filter((l) => l.startsWith("data:")).map((l) => l.slice(5).trimStart()).join("\n");
|
|
96
|
+
if (!data) continue;
|
|
97
|
+
if (data === "[DONE]") return;
|
|
98
|
+
let obj;
|
|
99
|
+
try {
|
|
100
|
+
obj = JSON.parse(data);
|
|
101
|
+
} catch {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (obj.error && typeof obj.error === "object") throw onError(obj.error);
|
|
105
|
+
yield obj;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} finally {
|
|
109
|
+
reader.releaseLock();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/transport.ts
|
|
114
|
+
function toQuery(q) {
|
|
115
|
+
if (!q) return "";
|
|
116
|
+
const sp = new URLSearchParams();
|
|
117
|
+
for (const [k, v] of Object.entries(q)) {
|
|
118
|
+
if (v === void 0 || v === null || v === "") continue;
|
|
119
|
+
sp.set(k, Array.isArray(v) ? v.join(",") : String(v));
|
|
120
|
+
}
|
|
121
|
+
const s = sp.toString();
|
|
122
|
+
return s ? `?${s}` : "";
|
|
123
|
+
}
|
|
124
|
+
async function json(t, method, path, init) {
|
|
125
|
+
const res = await t.send(method, path, init);
|
|
126
|
+
if (res.ok) return await res.json();
|
|
127
|
+
throw await toError(t, res);
|
|
128
|
+
}
|
|
129
|
+
async function toError(t, res) {
|
|
130
|
+
if (t.browser && res.status === 404 && !(res.headers.get("content-type") ?? "").includes("json")) {
|
|
131
|
+
return new AcademyError("IDENTITY_EXPIRED", "\u9019\u500B\u7DB2\u5740\u6C92\u6709\u5E73\u53F0\u4FDD\u7559\u8DEF\u5F91\uFF08\u5C1A\u672A\u555F\u7528\u5165\u53E3\u95DC\u5361\uFF09\uFF0C\u7121\u6CD5\u4F7F\u7528\u5E73\u53F0\u8CC7\u6E90", 404);
|
|
132
|
+
}
|
|
133
|
+
return await errorFromResponse(res);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/ai.ts
|
|
137
|
+
function createAiClient(t, base, opts) {
|
|
138
|
+
async function create(body) {
|
|
139
|
+
if (!body.stream) return await json(t, "POST", `${base}/chat/completions`, { body });
|
|
140
|
+
const res = await t.send("POST", `${base}/chat/completions`, { body });
|
|
141
|
+
if (!res.ok || !res.body) throw await toError(t, res);
|
|
142
|
+
const stream = res.body;
|
|
143
|
+
return {
|
|
144
|
+
[Symbol.asyncIterator]: () => parseSse(stream, (e) => new AcademyError(typeof e.code === "string" ? e.code : "AI_UNAVAILABLE", typeof e.message === "string" ? e.message : "\u4E32\u6D41\u4E2D\u65B7", 0, e))
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
chat: { completions: { create } },
|
|
149
|
+
images: { generate: (body) => json(t, "POST", `${base}/images/generations`, { body }) },
|
|
150
|
+
audio: {
|
|
151
|
+
speech: {
|
|
152
|
+
create: (body) => {
|
|
153
|
+
if (!opts.speech) return Promise.reject(new AcademyError("INVALID_REQUEST", "\u700F\u89BD\u5668\u7AEF\u4E0D\u63D0\u4F9B\u8A9E\u97F3\uFF0C\u8ACB\u7531 App \u5F8C\u7AEF\u547C\u53EB", 0));
|
|
154
|
+
return json(t, "POST", `${base}/audio/speech`, { body });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/od.ts
|
|
162
|
+
function createOdClient(t, base) {
|
|
163
|
+
const get = (resource, q) => json(t, "GET", `${base}/${resource.replace(/^\/+/, "")}`, { query: q ?? {} });
|
|
164
|
+
const typed = (resource, q) => get(resource, q);
|
|
165
|
+
return {
|
|
166
|
+
lvr: {
|
|
167
|
+
deals: (q) => get("lvr/deals", q),
|
|
168
|
+
marketContext: (q) => get("lvr/market-context", q),
|
|
169
|
+
deal: (id) => typed("lvr/deal", { id }),
|
|
170
|
+
similar: (q) => typed("lvr/similar", q),
|
|
171
|
+
summary: (q) => typed("lvr/summary", q),
|
|
172
|
+
statsByArea: (q) => typed("lvr/stats/by-area", q ?? {}),
|
|
173
|
+
monthlyTrend: (q) => typed("lvr/stats/monthly-trend", q),
|
|
174
|
+
rentalStats: (q) => typed("lvr/stats/rental", q),
|
|
175
|
+
monthlyByRegion: (q) => typed("lvr/monthly-by-region", q)
|
|
176
|
+
},
|
|
177
|
+
nearby: { deals: (q) => get("nearby/deals", q), amenities: (q) => get("nearby/amenities", q), comparables: (q) => get("nearby/comparables", q) },
|
|
178
|
+
address: { convert: (q) => get("address/convert", q), suggest: (q) => typed("address/suggest", q), geocode: (q) => typed("address/geocode", q) },
|
|
179
|
+
area: { profile: (q) => get("area/profile", q), series: (q) => typed("area/series", q) },
|
|
180
|
+
communities: {
|
|
181
|
+
suggest: (q) => typed("communities/suggest", q),
|
|
182
|
+
match: (q) => typed("communities/match", q),
|
|
183
|
+
nearby: (q) => typed("communities/nearby", q),
|
|
184
|
+
inBounds: (q) => typed("communities/in-bounds", q),
|
|
185
|
+
byArea: (q) => typed("communities/by-area", q),
|
|
186
|
+
get: (id) => typed("communities/detail", { id })
|
|
187
|
+
},
|
|
188
|
+
schools: {
|
|
189
|
+
nearby: (q) => typed("schools/nearby", q),
|
|
190
|
+
search: (q) => typed("schools/search", q),
|
|
191
|
+
// 閘道只有 GET:座標串成「緯度,經度;緯度,經度」一個參數
|
|
192
|
+
nearbyBatch: (points) => typed("schools/nearby-batch", { points: points.map((p) => `${p.lat},${p.lng}`).join(";") })
|
|
193
|
+
},
|
|
194
|
+
population: { village: (q) => typed("population/village", q) },
|
|
195
|
+
stats: {
|
|
196
|
+
villages: (q) => typed("stats/villages", q),
|
|
197
|
+
cpi: (q) => typed("stats/cpi", q ?? {}),
|
|
198
|
+
market: (q) => typed("stats/market", q)
|
|
199
|
+
},
|
|
200
|
+
hazards: (q) => get("hazards", q),
|
|
201
|
+
// 既有的 `marketBriefs(q)` 呼叫不變,另掛 `list` 方法
|
|
202
|
+
marketBriefs: Object.assign((q) => get("market-briefs", q), {
|
|
203
|
+
list: (q) => typed("market-briefs/list", q ?? {})
|
|
204
|
+
}),
|
|
205
|
+
bulletins: {
|
|
206
|
+
list: (q) => typed("bulletins", q ?? {}),
|
|
207
|
+
get: (id) => typed("bulletins/detail", { id }),
|
|
208
|
+
documents: (id, q) => typed("bulletins/documents", { ...q ?? {}, id })
|
|
209
|
+
},
|
|
210
|
+
briefs: {
|
|
211
|
+
latest: (q) => typed("briefs/latest", q ?? {}),
|
|
212
|
+
get: (q) => typed("briefs", q),
|
|
213
|
+
list: (q) => typed("briefs/list", q ?? {}),
|
|
214
|
+
coverage: (q) => typed("briefs/coverage", q ?? {})
|
|
215
|
+
},
|
|
216
|
+
newsReports: {
|
|
217
|
+
latest: (q) => typed("news-reports/latest", q ?? {}),
|
|
218
|
+
get: (q) => typed("news-reports", q),
|
|
219
|
+
list: (q) => typed("news-reports/list", q ?? {}),
|
|
220
|
+
topics: (q) => typed("news-topics", q ?? {})
|
|
221
|
+
},
|
|
222
|
+
tax: { houseRates: (q) => get("tax/house-rates", q) },
|
|
223
|
+
judgments: { search: (q) => get("judgments", q), get: (id) => get("judgments", { id }), meta: () => get("judgments/meta") },
|
|
224
|
+
// 閘道只有 GET:多邊形與座標清單都串成一個參數
|
|
225
|
+
spatial: {
|
|
226
|
+
lvrSummary: (q) => typed("spatial/lvr-summary", { ...q, polygon: polygonParam(q.polygon) }),
|
|
227
|
+
companies: (q) => typed("spatial/companies", { ...q, polygon: polygonParam(q.polygon) }),
|
|
228
|
+
villages: (q) => typed("spatial/villages", { ...q, polygon: polygonParam(q.polygon) }),
|
|
229
|
+
villageGeometry: (q) => typed("spatial/villages/geometry", q),
|
|
230
|
+
boundaries: (q) => typed("spatial/boundaries", q),
|
|
231
|
+
lookup: (q) => typed("spatial/boundaries/lookup", { ...q, ...q.names !== void 0 ? { names: namesParam(q.names) } : {} })
|
|
232
|
+
},
|
|
233
|
+
zoning: {
|
|
234
|
+
batch: (points) => typed("zoning/batch", { points: points.map((p) => `${p.lat},${p.lng}`).join(";") }),
|
|
235
|
+
tiles: () => typed("zoning/tiles-config", {}),
|
|
236
|
+
geojson: (q) => typed("zoning/geojson", q)
|
|
237
|
+
},
|
|
238
|
+
cadastre: {
|
|
239
|
+
sections: (q) => typed("cadastre/sections", q),
|
|
240
|
+
reversePoint: (q) => typed("cadastre/reverse-point", q),
|
|
241
|
+
landInfo: (q) => typed("cadastre/land-info", q),
|
|
242
|
+
locateSources: () => typed("cadastre/locate-sources", {}),
|
|
243
|
+
tiles: () => typed("cadastre/tiles-config", {})
|
|
244
|
+
},
|
|
245
|
+
layers: {
|
|
246
|
+
heat: {
|
|
247
|
+
deals: (q) => typed("layers/heat/deals", q),
|
|
248
|
+
amenities: (q) => typed("layers/heat/amenities", q),
|
|
249
|
+
transport: (q) => typed("layers/heat/transport", q),
|
|
250
|
+
population: (q) => typed("layers/heat/population", q),
|
|
251
|
+
hazards: (q) => typed("layers/heat/hazards", q)
|
|
252
|
+
},
|
|
253
|
+
hazardZones: (q) => typed("layers/hazard-zones", q),
|
|
254
|
+
poi: (q) => typed("layers/poi", q),
|
|
255
|
+
choropleth: (q) => typed("layers/choropleth", q)
|
|
256
|
+
},
|
|
257
|
+
licenses: {
|
|
258
|
+
penalties: (q) => typed("licenses/penalties", q ?? {})
|
|
259
|
+
},
|
|
260
|
+
factories: {
|
|
261
|
+
nearby: (q) => typed("factories/nearby", q),
|
|
262
|
+
search: (q) => typed("factories", q ?? {})
|
|
263
|
+
},
|
|
264
|
+
calendar: { holidays: (q) => typed("holidays", q) },
|
|
265
|
+
get
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function polygonParam(p) {
|
|
269
|
+
if (typeof p === "string") return p;
|
|
270
|
+
return p.map((v) => Array.isArray(v) ? `${v[0]},${v[1]}` : `${v.lat},${v.lng}`).join(";");
|
|
271
|
+
}
|
|
272
|
+
function namesParam(n) {
|
|
273
|
+
if (typeof n === "string") return n;
|
|
274
|
+
return n.map((x) => x.district ? `${x.city}/${x.district}` : x.city).join(";");
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/version.ts
|
|
278
|
+
var SDK_VERSION = "2.6.0";
|
|
279
|
+
var CONTRACT_VERSION = 2;
|
|
280
|
+
|
|
281
|
+
// src/browser.ts
|
|
282
|
+
var transport = {
|
|
283
|
+
browser: true,
|
|
284
|
+
send: (method, path, init) => fetch(`${path}${toQuery(init?.query)}`, {
|
|
285
|
+
method,
|
|
286
|
+
credentials: "same-origin",
|
|
287
|
+
headers: { "X-Academy-SDK": SDK_VERSION, ...init?.body !== void 0 ? { "Content-Type": "application/json" } : {} },
|
|
288
|
+
body: init?.body !== void 0 ? JSON.stringify(init.body) : void 0
|
|
289
|
+
})
|
|
290
|
+
};
|
|
291
|
+
var academyBrowser = {
|
|
292
|
+
/**
|
|
293
|
+
* 目前的身分、訂閱狀態與點數;同時向平台握手(純前端 App 的上架自檢以此為準)。
|
|
294
|
+
* 保留路徑不存在(尚未啟用入口關卡)時回 null;未登入、沒有訂閱、工具暫停等丟 AcademyError(看 `code`)。
|
|
295
|
+
*/
|
|
296
|
+
async me() {
|
|
297
|
+
let res;
|
|
298
|
+
try {
|
|
299
|
+
res = await transport.send("GET", "/__academy/me");
|
|
300
|
+
} catch {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
if (res.ok) return await res.json();
|
|
304
|
+
const err = await toError(transport, res);
|
|
305
|
+
if (err.code === "IDENTITY_EXPIRED" && res.status === 404) return null;
|
|
306
|
+
throw err;
|
|
307
|
+
},
|
|
308
|
+
/** 平台 AI:對話(含串流)與圖片生成;語音請由 App 後端呼叫 */
|
|
309
|
+
ai() {
|
|
310
|
+
return createAiClient(transport, "/__academy/ai", { speech: false });
|
|
311
|
+
},
|
|
312
|
+
/** 房市資料 */
|
|
313
|
+
od() {
|
|
314
|
+
return createOdClient(transport, "/__academy/od");
|
|
315
|
+
},
|
|
316
|
+
/** 登出這個 App(清除 App cookie 後回到研究所首頁) */
|
|
317
|
+
logout() {
|
|
318
|
+
window.location.href = "/__academy/logout";
|
|
319
|
+
},
|
|
320
|
+
/** 依錯誤碼導到平台頁面(登入、訂閱、升級);處理了回 true */
|
|
321
|
+
redirectFor(err) {
|
|
322
|
+
if (!(err instanceof AcademyError)) return false;
|
|
323
|
+
const url = err.loginUrl ?? err.subscribeUrl ?? err.upgradeUrl;
|
|
324
|
+
if (!url) return false;
|
|
325
|
+
window.location.href = url;
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
330
|
+
0 && (module.exports = {
|
|
331
|
+
AcademyError,
|
|
332
|
+
CONTRACT_VERSION,
|
|
333
|
+
SDK_VERSION,
|
|
334
|
+
academyBrowser
|
|
335
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { A as AcademyAI, a as AcademyOD } from './od-BVdmZf1t.cjs';
|
|
2
|
+
export { O as OdAddressGeocodeQuery, b as OdAddressGeocodeResult, c as OdAddressSuggestQuery, d as OdAddressSuggestResult, e as OdAdminLevel, f as OdAreaSeriesItem, g as OdAreaSeriesQuery, h as OdAreaSeriesResult, i as OdBbox, j as OdBoundaryLookupQuery, k as OdBoundaryLookupResult, l as OdBoundaryProperties, m as OdBriefCoverageResult, n as OdBriefIndicator, o as OdBriefListResult, p as OdBriefResult, q as OdBulletin, r as OdBulletinDetail, s as OdBulletinDetailResult, t as OdBulletinDocumentsQuery, u as OdBulletinDocumentsResult, v as OdBulletinsListQuery, w as OdBulletinsListResult, x as OdCadastreLandInfoResult, y as OdCadastreReversePointResult, z as OdCadastreSection, B as OdCadastreSectionsQuery, C as OdCadastreSectionsResult, D as OdCalendarDay, E as OdCalendarHolidaysResult, F as OdCenter, G as OdChoroplethMetric, H as OdChoroplethResult, I as OdCommunity, J as OdCommunityByAreaQuery, K as OdCommunityByAreaResult, L as OdCommunityDetail, M as OdCommunityDetailResult, N as OdCommunityInBoundsQuery, P as OdCommunityListResult, Q as OdCommunityMatchItem, R as OdCommunityMatchQuery, S as OdCommunityMatchResult, T as OdCommunityNearbyQuery, U as OdCommunityPrice, V as OdCommunitySuggestQuery, W as OdDayType, X as OdFactoriesNearbyQuery, Y as OdFactoriesNearbyResult, Z as OdFactoriesSearchQuery, _ as OdFactoriesSearchResult, $ as OdFactory, a0 as OdFactoryCoverage, a1 as OdFeature, a2 as OdFeatureCollection, a3 as OdGeocodePrecision, a4 as OdGeocodeSource, a5 as OdGeocodeStatus, a6 as OdGeometry, a7 as OdHazardType, a8 as OdHeatDealsQuery, a9 as OdHeatResult, aa as OdHeatTypesQuery, ab as OdIndicatorComparison, ac as OdLicensePenaltiesResult, ad as OdLicensePenalty, ae as OdLocation, af as OdLvrBase, ag as OdLvrDeal, ah as OdLvrDealMoney, ai as OdLvrDealResult, aj as OdLvrMonthlyByRegionQuery, ak as OdLvrMonthlyByRegionResult, al as OdLvrMonthlyTrendQuery, am as OdLvrMonthlyTrendResult, an as OdLvrRentalStatsQuery, ao as OdLvrRentalStatsResult, ap as OdLvrSimilarItem, aq as OdLvrSimilarQuery, ar as OdLvrSimilarResult, as as OdLvrStatsByAreaQuery, at as OdLvrStatsByAreaResult, au as OdLvrSummaryQuery, av as OdLvrSummaryResult, aw as OdLvrTarget, ax as OdLvrTransactionType, ay as OdMarketIndicator, az as OdNewsReportResult, aA as OdNewsTopicsQuery, aB as OdNewsTopicsResult, aC as OdNoticeBase, aD as OdPeriodGetQuery, aE as OdPeriodListQuery, aF as OdPeriodType, aG as OdPeriodViewQuery, aH as OdPoiPointsResult, aI as OdPoiType, aJ as OdPoint, aK as OdPolygon, aL as OdPopulationVillageResult, aM as OdPublicFact, aN as OdPublicSource, aO as OdQuery, aP as OdReportEvent, aQ as OdReportListResult, aR as OdReportQuote, aS as OdResult, aT as OdSchool, aU as OdSchoolLevel, aV as OdSchoolsNearbyBatchResult, aW as OdSchoolsNearbyQuery, aX as OdSchoolsNearbyResult, aY as OdSchoolsSearchQuery, aZ as OdSchoolsSearchResult, a_ as OdSeries, a$ as OdSpatialCompaniesQuery, b0 as OdSpatialCompaniesResult, b1 as OdSpatialLvrSummaryQuery, b2 as OdSpatialLvrSummaryResult, b3 as OdSpatialVillageGeometryResult, b4 as OdSpatialVillagesResult, b5 as OdStatsCpiQuery, b6 as OdStatsCpiResult, b7 as OdStatsMarketQuery, b8 as OdStatsMarketResult, b9 as OdStatsVillagesQuery, ba as OdStatsVillagesResult, bb as OdTileLayer, bc as OdTilesResult, bd as OdUsagePolicy, be as OdVillageStatsItem, bf as OdZoning, bg as OdZoningBatchResult, bh as OdZoningFeatureProperties, bi as OdZoningLayer } from './od-BVdmZf1t.cjs';
|
|
3
|
+
import { A as AcademyMe } from './version-ClrVQNzw.cjs';
|
|
4
|
+
export { a as AcademyClientInfo, b as AcademyContext, c as AcademyEntitlement, d as AcademyError, e as AcademyErrorCode, f as AcademyJobInfo, g as AcademyQuota, h as AcademyServiceContext, i as AcademyUser, j as AppClientKind, k as AppEntitlementKind, l as AppEntitlementReason, m as AppIdentityEnv, n as AppJobStatus, C as CONTRACT_VERSION, o as ChatCompletion, p as ChatCompletionChunk, q as ChatCompletionRequest, r as ChatMessage, s as ChatRole, I as ImageGenerateRequest, t as ImageGenerateResponse, M as MemberEntitlement, u as MembershipTier, S as SDK_VERSION, v as SpeechRequest, w as SpeechResponse } from './version-ClrVQNzw.cjs';
|
|
5
|
+
|
|
6
|
+
declare const academyBrowser: {
|
|
7
|
+
/**
|
|
8
|
+
* 目前的身分、訂閱狀態與點數;同時向平台握手(純前端 App 的上架自檢以此為準)。
|
|
9
|
+
* 保留路徑不存在(尚未啟用入口關卡)時回 null;未登入、沒有訂閱、工具暫停等丟 AcademyError(看 `code`)。
|
|
10
|
+
*/
|
|
11
|
+
me(): Promise<AcademyMe | null>;
|
|
12
|
+
/** 平台 AI:對話(含串流)與圖片生成;語音請由 App 後端呼叫 */
|
|
13
|
+
ai(): AcademyAI;
|
|
14
|
+
/** 房市資料 */
|
|
15
|
+
od(): AcademyOD;
|
|
16
|
+
/** 登出這個 App(清除 App cookie 後回到研究所首頁) */
|
|
17
|
+
logout(): void;
|
|
18
|
+
/** 依錯誤碼導到平台頁面(登入、訂閱、升級);處理了回 true */
|
|
19
|
+
redirectFor(err: unknown): boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { AcademyAI, AcademyMe, AcademyOD, academyBrowser };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { A as AcademyAI, a as AcademyOD } from './od-sGQixHat.js';
|
|
2
|
+
export { O as OdAddressGeocodeQuery, b as OdAddressGeocodeResult, c as OdAddressSuggestQuery, d as OdAddressSuggestResult, e as OdAdminLevel, f as OdAreaSeriesItem, g as OdAreaSeriesQuery, h as OdAreaSeriesResult, i as OdBbox, j as OdBoundaryLookupQuery, k as OdBoundaryLookupResult, l as OdBoundaryProperties, m as OdBriefCoverageResult, n as OdBriefIndicator, o as OdBriefListResult, p as OdBriefResult, q as OdBulletin, r as OdBulletinDetail, s as OdBulletinDetailResult, t as OdBulletinDocumentsQuery, u as OdBulletinDocumentsResult, v as OdBulletinsListQuery, w as OdBulletinsListResult, x as OdCadastreLandInfoResult, y as OdCadastreReversePointResult, z as OdCadastreSection, B as OdCadastreSectionsQuery, C as OdCadastreSectionsResult, D as OdCalendarDay, E as OdCalendarHolidaysResult, F as OdCenter, G as OdChoroplethMetric, H as OdChoroplethResult, I as OdCommunity, J as OdCommunityByAreaQuery, K as OdCommunityByAreaResult, L as OdCommunityDetail, M as OdCommunityDetailResult, N as OdCommunityInBoundsQuery, P as OdCommunityListResult, Q as OdCommunityMatchItem, R as OdCommunityMatchQuery, S as OdCommunityMatchResult, T as OdCommunityNearbyQuery, U as OdCommunityPrice, V as OdCommunitySuggestQuery, W as OdDayType, X as OdFactoriesNearbyQuery, Y as OdFactoriesNearbyResult, Z as OdFactoriesSearchQuery, _ as OdFactoriesSearchResult, $ as OdFactory, a0 as OdFactoryCoverage, a1 as OdFeature, a2 as OdFeatureCollection, a3 as OdGeocodePrecision, a4 as OdGeocodeSource, a5 as OdGeocodeStatus, a6 as OdGeometry, a7 as OdHazardType, a8 as OdHeatDealsQuery, a9 as OdHeatResult, aa as OdHeatTypesQuery, ab as OdIndicatorComparison, ac as OdLicensePenaltiesResult, ad as OdLicensePenalty, ae as OdLocation, af as OdLvrBase, ag as OdLvrDeal, ah as OdLvrDealMoney, ai as OdLvrDealResult, aj as OdLvrMonthlyByRegionQuery, ak as OdLvrMonthlyByRegionResult, al as OdLvrMonthlyTrendQuery, am as OdLvrMonthlyTrendResult, an as OdLvrRentalStatsQuery, ao as OdLvrRentalStatsResult, ap as OdLvrSimilarItem, aq as OdLvrSimilarQuery, ar as OdLvrSimilarResult, as as OdLvrStatsByAreaQuery, at as OdLvrStatsByAreaResult, au as OdLvrSummaryQuery, av as OdLvrSummaryResult, aw as OdLvrTarget, ax as OdLvrTransactionType, ay as OdMarketIndicator, az as OdNewsReportResult, aA as OdNewsTopicsQuery, aB as OdNewsTopicsResult, aC as OdNoticeBase, aD as OdPeriodGetQuery, aE as OdPeriodListQuery, aF as OdPeriodType, aG as OdPeriodViewQuery, aH as OdPoiPointsResult, aI as OdPoiType, aJ as OdPoint, aK as OdPolygon, aL as OdPopulationVillageResult, aM as OdPublicFact, aN as OdPublicSource, aO as OdQuery, aP as OdReportEvent, aQ as OdReportListResult, aR as OdReportQuote, aS as OdResult, aT as OdSchool, aU as OdSchoolLevel, aV as OdSchoolsNearbyBatchResult, aW as OdSchoolsNearbyQuery, aX as OdSchoolsNearbyResult, aY as OdSchoolsSearchQuery, aZ as OdSchoolsSearchResult, a_ as OdSeries, a$ as OdSpatialCompaniesQuery, b0 as OdSpatialCompaniesResult, b1 as OdSpatialLvrSummaryQuery, b2 as OdSpatialLvrSummaryResult, b3 as OdSpatialVillageGeometryResult, b4 as OdSpatialVillagesResult, b5 as OdStatsCpiQuery, b6 as OdStatsCpiResult, b7 as OdStatsMarketQuery, b8 as OdStatsMarketResult, b9 as OdStatsVillagesQuery, ba as OdStatsVillagesResult, bb as OdTileLayer, bc as OdTilesResult, bd as OdUsagePolicy, be as OdVillageStatsItem, bf as OdZoning, bg as OdZoningBatchResult, bh as OdZoningFeatureProperties, bi as OdZoningLayer } from './od-sGQixHat.js';
|
|
3
|
+
import { A as AcademyMe } from './version-ClrVQNzw.js';
|
|
4
|
+
export { a as AcademyClientInfo, b as AcademyContext, c as AcademyEntitlement, d as AcademyError, e as AcademyErrorCode, f as AcademyJobInfo, g as AcademyQuota, h as AcademyServiceContext, i as AcademyUser, j as AppClientKind, k as AppEntitlementKind, l as AppEntitlementReason, m as AppIdentityEnv, n as AppJobStatus, C as CONTRACT_VERSION, o as ChatCompletion, p as ChatCompletionChunk, q as ChatCompletionRequest, r as ChatMessage, s as ChatRole, I as ImageGenerateRequest, t as ImageGenerateResponse, M as MemberEntitlement, u as MembershipTier, S as SDK_VERSION, v as SpeechRequest, w as SpeechResponse } from './version-ClrVQNzw.js';
|
|
5
|
+
|
|
6
|
+
declare const academyBrowser: {
|
|
7
|
+
/**
|
|
8
|
+
* 目前的身分、訂閱狀態與點數;同時向平台握手(純前端 App 的上架自檢以此為準)。
|
|
9
|
+
* 保留路徑不存在(尚未啟用入口關卡)時回 null;未登入、沒有訂閱、工具暫停等丟 AcademyError(看 `code`)。
|
|
10
|
+
*/
|
|
11
|
+
me(): Promise<AcademyMe | null>;
|
|
12
|
+
/** 平台 AI:對話(含串流)與圖片生成;語音請由 App 後端呼叫 */
|
|
13
|
+
ai(): AcademyAI;
|
|
14
|
+
/** 房市資料 */
|
|
15
|
+
od(): AcademyOD;
|
|
16
|
+
/** 登出這個 App(清除 App cookie 後回到研究所首頁) */
|
|
17
|
+
logout(): void;
|
|
18
|
+
/** 依錯誤碼導到平台頁面(登入、訂閱、升級);處理了回 true */
|
|
19
|
+
redirectFor(err: unknown): boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { AcademyAI, AcademyMe, AcademyOD, academyBrowser };
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAiClient,
|
|
3
|
+
createOdClient,
|
|
4
|
+
toError,
|
|
5
|
+
toQuery
|
|
6
|
+
} from "./chunk-4KBWZDXW.js";
|
|
7
|
+
import {
|
|
8
|
+
AcademyError,
|
|
9
|
+
CONTRACT_VERSION,
|
|
10
|
+
SDK_VERSION
|
|
11
|
+
} from "./chunk-VCZOS6GJ.js";
|
|
12
|
+
|
|
13
|
+
// src/browser.ts
|
|
14
|
+
var transport = {
|
|
15
|
+
browser: true,
|
|
16
|
+
send: (method, path, init) => fetch(`${path}${toQuery(init?.query)}`, {
|
|
17
|
+
method,
|
|
18
|
+
credentials: "same-origin",
|
|
19
|
+
headers: { "X-Academy-SDK": SDK_VERSION, ...init?.body !== void 0 ? { "Content-Type": "application/json" } : {} },
|
|
20
|
+
body: init?.body !== void 0 ? JSON.stringify(init.body) : void 0
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
var academyBrowser = {
|
|
24
|
+
/**
|
|
25
|
+
* 目前的身分、訂閱狀態與點數;同時向平台握手(純前端 App 的上架自檢以此為準)。
|
|
26
|
+
* 保留路徑不存在(尚未啟用入口關卡)時回 null;未登入、沒有訂閱、工具暫停等丟 AcademyError(看 `code`)。
|
|
27
|
+
*/
|
|
28
|
+
async me() {
|
|
29
|
+
let res;
|
|
30
|
+
try {
|
|
31
|
+
res = await transport.send("GET", "/__academy/me");
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (res.ok) return await res.json();
|
|
36
|
+
const err = await toError(transport, res);
|
|
37
|
+
if (err.code === "IDENTITY_EXPIRED" && res.status === 404) return null;
|
|
38
|
+
throw err;
|
|
39
|
+
},
|
|
40
|
+
/** 平台 AI:對話(含串流)與圖片生成;語音請由 App 後端呼叫 */
|
|
41
|
+
ai() {
|
|
42
|
+
return createAiClient(transport, "/__academy/ai", { speech: false });
|
|
43
|
+
},
|
|
44
|
+
/** 房市資料 */
|
|
45
|
+
od() {
|
|
46
|
+
return createOdClient(transport, "/__academy/od");
|
|
47
|
+
},
|
|
48
|
+
/** 登出這個 App(清除 App cookie 後回到研究所首頁) */
|
|
49
|
+
logout() {
|
|
50
|
+
window.location.href = "/__academy/logout";
|
|
51
|
+
},
|
|
52
|
+
/** 依錯誤碼導到平台頁面(登入、訂閱、升級);處理了回 true */
|
|
53
|
+
redirectFor(err) {
|
|
54
|
+
if (!(err instanceof AcademyError)) return false;
|
|
55
|
+
const url = err.loginUrl ?? err.subscribeUrl ?? err.upgradeUrl;
|
|
56
|
+
if (!url) return false;
|
|
57
|
+
window.location.href = url;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
AcademyError,
|
|
63
|
+
CONTRACT_VERSION,
|
|
64
|
+
SDK_VERSION,
|
|
65
|
+
academyBrowser
|
|
66
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AcademyError,
|
|
3
|
+
errorFromResponse
|
|
4
|
+
} from "./chunk-VCZOS6GJ.js";
|
|
5
|
+
|
|
6
|
+
// src/transport.ts
|
|
7
|
+
function toQuery(q) {
|
|
8
|
+
if (!q) return "";
|
|
9
|
+
const sp = new URLSearchParams();
|
|
10
|
+
for (const [k, v] of Object.entries(q)) {
|
|
11
|
+
if (v === void 0 || v === null || v === "") continue;
|
|
12
|
+
sp.set(k, Array.isArray(v) ? v.join(",") : String(v));
|
|
13
|
+
}
|
|
14
|
+
const s = sp.toString();
|
|
15
|
+
return s ? `?${s}` : "";
|
|
16
|
+
}
|
|
17
|
+
async function json(t, method, path, init) {
|
|
18
|
+
const res = await t.send(method, path, init);
|
|
19
|
+
if (res.ok) return await res.json();
|
|
20
|
+
throw await toError(t, res);
|
|
21
|
+
}
|
|
22
|
+
async function toError(t, res) {
|
|
23
|
+
if (t.browser && res.status === 404 && !(res.headers.get("content-type") ?? "").includes("json")) {
|
|
24
|
+
return new AcademyError("IDENTITY_EXPIRED", "\u9019\u500B\u7DB2\u5740\u6C92\u6709\u5E73\u53F0\u4FDD\u7559\u8DEF\u5F91\uFF08\u5C1A\u672A\u555F\u7528\u5165\u53E3\u95DC\u5361\uFF09\uFF0C\u7121\u6CD5\u4F7F\u7528\u5E73\u53F0\u8CC7\u6E90", 404);
|
|
25
|
+
}
|
|
26
|
+
return await errorFromResponse(res);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/sse.ts
|
|
30
|
+
async function* parseSse(body, onError) {
|
|
31
|
+
const reader = body.getReader();
|
|
32
|
+
const decoder = new TextDecoder();
|
|
33
|
+
let buf = "";
|
|
34
|
+
try {
|
|
35
|
+
for (; ; ) {
|
|
36
|
+
const { done, value } = await reader.read();
|
|
37
|
+
if (done) break;
|
|
38
|
+
buf += decoder.decode(value, { stream: true });
|
|
39
|
+
let idx;
|
|
40
|
+
while ((idx = buf.search(/\r?\n\r?\n/)) >= 0) {
|
|
41
|
+
const event = buf.slice(0, idx);
|
|
42
|
+
buf = buf.slice(idx).replace(/^\r?\n\r?\n/, "");
|
|
43
|
+
const data = event.split(/\r?\n/).filter((l) => l.startsWith("data:")).map((l) => l.slice(5).trimStart()).join("\n");
|
|
44
|
+
if (!data) continue;
|
|
45
|
+
if (data === "[DONE]") return;
|
|
46
|
+
let obj;
|
|
47
|
+
try {
|
|
48
|
+
obj = JSON.parse(data);
|
|
49
|
+
} catch {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (obj.error && typeof obj.error === "object") throw onError(obj.error);
|
|
53
|
+
yield obj;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
reader.releaseLock();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/ai.ts
|
|
62
|
+
function createAiClient(t, base, opts) {
|
|
63
|
+
async function create(body) {
|
|
64
|
+
if (!body.stream) return await json(t, "POST", `${base}/chat/completions`, { body });
|
|
65
|
+
const res = await t.send("POST", `${base}/chat/completions`, { body });
|
|
66
|
+
if (!res.ok || !res.body) throw await toError(t, res);
|
|
67
|
+
const stream = res.body;
|
|
68
|
+
return {
|
|
69
|
+
[Symbol.asyncIterator]: () => parseSse(stream, (e) => new AcademyError(typeof e.code === "string" ? e.code : "AI_UNAVAILABLE", typeof e.message === "string" ? e.message : "\u4E32\u6D41\u4E2D\u65B7", 0, e))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
chat: { completions: { create } },
|
|
74
|
+
images: { generate: (body) => json(t, "POST", `${base}/images/generations`, { body }) },
|
|
75
|
+
audio: {
|
|
76
|
+
speech: {
|
|
77
|
+
create: (body) => {
|
|
78
|
+
if (!opts.speech) return Promise.reject(new AcademyError("INVALID_REQUEST", "\u700F\u89BD\u5668\u7AEF\u4E0D\u63D0\u4F9B\u8A9E\u97F3\uFF0C\u8ACB\u7531 App \u5F8C\u7AEF\u547C\u53EB", 0));
|
|
79
|
+
return json(t, "POST", `${base}/audio/speech`, { body });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/od.ts
|
|
87
|
+
function createOdClient(t, base) {
|
|
88
|
+
const get = (resource, q) => json(t, "GET", `${base}/${resource.replace(/^\/+/, "")}`, { query: q ?? {} });
|
|
89
|
+
const typed = (resource, q) => get(resource, q);
|
|
90
|
+
return {
|
|
91
|
+
lvr: {
|
|
92
|
+
deals: (q) => get("lvr/deals", q),
|
|
93
|
+
marketContext: (q) => get("lvr/market-context", q),
|
|
94
|
+
deal: (id) => typed("lvr/deal", { id }),
|
|
95
|
+
similar: (q) => typed("lvr/similar", q),
|
|
96
|
+
summary: (q) => typed("lvr/summary", q),
|
|
97
|
+
statsByArea: (q) => typed("lvr/stats/by-area", q ?? {}),
|
|
98
|
+
monthlyTrend: (q) => typed("lvr/stats/monthly-trend", q),
|
|
99
|
+
rentalStats: (q) => typed("lvr/stats/rental", q),
|
|
100
|
+
monthlyByRegion: (q) => typed("lvr/monthly-by-region", q)
|
|
101
|
+
},
|
|
102
|
+
nearby: { deals: (q) => get("nearby/deals", q), amenities: (q) => get("nearby/amenities", q), comparables: (q) => get("nearby/comparables", q) },
|
|
103
|
+
address: { convert: (q) => get("address/convert", q), suggest: (q) => typed("address/suggest", q), geocode: (q) => typed("address/geocode", q) },
|
|
104
|
+
area: { profile: (q) => get("area/profile", q), series: (q) => typed("area/series", q) },
|
|
105
|
+
communities: {
|
|
106
|
+
suggest: (q) => typed("communities/suggest", q),
|
|
107
|
+
match: (q) => typed("communities/match", q),
|
|
108
|
+
nearby: (q) => typed("communities/nearby", q),
|
|
109
|
+
inBounds: (q) => typed("communities/in-bounds", q),
|
|
110
|
+
byArea: (q) => typed("communities/by-area", q),
|
|
111
|
+
get: (id) => typed("communities/detail", { id })
|
|
112
|
+
},
|
|
113
|
+
schools: {
|
|
114
|
+
nearby: (q) => typed("schools/nearby", q),
|
|
115
|
+
search: (q) => typed("schools/search", q),
|
|
116
|
+
// 閘道只有 GET:座標串成「緯度,經度;緯度,經度」一個參數
|
|
117
|
+
nearbyBatch: (points) => typed("schools/nearby-batch", { points: points.map((p) => `${p.lat},${p.lng}`).join(";") })
|
|
118
|
+
},
|
|
119
|
+
population: { village: (q) => typed("population/village", q) },
|
|
120
|
+
stats: {
|
|
121
|
+
villages: (q) => typed("stats/villages", q),
|
|
122
|
+
cpi: (q) => typed("stats/cpi", q ?? {}),
|
|
123
|
+
market: (q) => typed("stats/market", q)
|
|
124
|
+
},
|
|
125
|
+
hazards: (q) => get("hazards", q),
|
|
126
|
+
// 既有的 `marketBriefs(q)` 呼叫不變,另掛 `list` 方法
|
|
127
|
+
marketBriefs: Object.assign((q) => get("market-briefs", q), {
|
|
128
|
+
list: (q) => typed("market-briefs/list", q ?? {})
|
|
129
|
+
}),
|
|
130
|
+
bulletins: {
|
|
131
|
+
list: (q) => typed("bulletins", q ?? {}),
|
|
132
|
+
get: (id) => typed("bulletins/detail", { id }),
|
|
133
|
+
documents: (id, q) => typed("bulletins/documents", { ...q ?? {}, id })
|
|
134
|
+
},
|
|
135
|
+
briefs: {
|
|
136
|
+
latest: (q) => typed("briefs/latest", q ?? {}),
|
|
137
|
+
get: (q) => typed("briefs", q),
|
|
138
|
+
list: (q) => typed("briefs/list", q ?? {}),
|
|
139
|
+
coverage: (q) => typed("briefs/coverage", q ?? {})
|
|
140
|
+
},
|
|
141
|
+
newsReports: {
|
|
142
|
+
latest: (q) => typed("news-reports/latest", q ?? {}),
|
|
143
|
+
get: (q) => typed("news-reports", q),
|
|
144
|
+
list: (q) => typed("news-reports/list", q ?? {}),
|
|
145
|
+
topics: (q) => typed("news-topics", q ?? {})
|
|
146
|
+
},
|
|
147
|
+
tax: { houseRates: (q) => get("tax/house-rates", q) },
|
|
148
|
+
judgments: { search: (q) => get("judgments", q), get: (id) => get("judgments", { id }), meta: () => get("judgments/meta") },
|
|
149
|
+
// 閘道只有 GET:多邊形與座標清單都串成一個參數
|
|
150
|
+
spatial: {
|
|
151
|
+
lvrSummary: (q) => typed("spatial/lvr-summary", { ...q, polygon: polygonParam(q.polygon) }),
|
|
152
|
+
companies: (q) => typed("spatial/companies", { ...q, polygon: polygonParam(q.polygon) }),
|
|
153
|
+
villages: (q) => typed("spatial/villages", { ...q, polygon: polygonParam(q.polygon) }),
|
|
154
|
+
villageGeometry: (q) => typed("spatial/villages/geometry", q),
|
|
155
|
+
boundaries: (q) => typed("spatial/boundaries", q),
|
|
156
|
+
lookup: (q) => typed("spatial/boundaries/lookup", { ...q, ...q.names !== void 0 ? { names: namesParam(q.names) } : {} })
|
|
157
|
+
},
|
|
158
|
+
zoning: {
|
|
159
|
+
batch: (points) => typed("zoning/batch", { points: points.map((p) => `${p.lat},${p.lng}`).join(";") }),
|
|
160
|
+
tiles: () => typed("zoning/tiles-config", {}),
|
|
161
|
+
geojson: (q) => typed("zoning/geojson", q)
|
|
162
|
+
},
|
|
163
|
+
cadastre: {
|
|
164
|
+
sections: (q) => typed("cadastre/sections", q),
|
|
165
|
+
reversePoint: (q) => typed("cadastre/reverse-point", q),
|
|
166
|
+
landInfo: (q) => typed("cadastre/land-info", q),
|
|
167
|
+
locateSources: () => typed("cadastre/locate-sources", {}),
|
|
168
|
+
tiles: () => typed("cadastre/tiles-config", {})
|
|
169
|
+
},
|
|
170
|
+
layers: {
|
|
171
|
+
heat: {
|
|
172
|
+
deals: (q) => typed("layers/heat/deals", q),
|
|
173
|
+
amenities: (q) => typed("layers/heat/amenities", q),
|
|
174
|
+
transport: (q) => typed("layers/heat/transport", q),
|
|
175
|
+
population: (q) => typed("layers/heat/population", q),
|
|
176
|
+
hazards: (q) => typed("layers/heat/hazards", q)
|
|
177
|
+
},
|
|
178
|
+
hazardZones: (q) => typed("layers/hazard-zones", q),
|
|
179
|
+
poi: (q) => typed("layers/poi", q),
|
|
180
|
+
choropleth: (q) => typed("layers/choropleth", q)
|
|
181
|
+
},
|
|
182
|
+
licenses: {
|
|
183
|
+
penalties: (q) => typed("licenses/penalties", q ?? {})
|
|
184
|
+
},
|
|
185
|
+
factories: {
|
|
186
|
+
nearby: (q) => typed("factories/nearby", q),
|
|
187
|
+
search: (q) => typed("factories", q ?? {})
|
|
188
|
+
},
|
|
189
|
+
calendar: { holidays: (q) => typed("holidays", q) },
|
|
190
|
+
get
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function polygonParam(p) {
|
|
194
|
+
if (typeof p === "string") return p;
|
|
195
|
+
return p.map((v) => Array.isArray(v) ? `${v[0]},${v[1]}` : `${v.lat},${v.lng}`).join(";");
|
|
196
|
+
}
|
|
197
|
+
function namesParam(n) {
|
|
198
|
+
if (typeof n === "string") return n;
|
|
199
|
+
return n.map((x) => x.district ? `${x.city}/${x.district}` : x.city).join(";");
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
toQuery,
|
|
204
|
+
json,
|
|
205
|
+
toError,
|
|
206
|
+
createAiClient,
|
|
207
|
+
createOdClient
|
|
208
|
+
};
|