@xdmp-open/sdk-lowcode 0.0.0-stage → 0.0.1

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/index.js ADDED
@@ -0,0 +1,434 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/constants.ts
6
+ var LCDP_PREFIX = "/api/system";
7
+
8
+ // src/resources/base.ts
9
+ function resolveResourceUrl(prefix, path, pathVars) {
10
+ const resolved = pathVars ? path.replace(/\{(\w+)\}/g, (_, key) => {
11
+ const raw = pathVars[key];
12
+ if (raw == null || String(raw).trim() === "") {
13
+ throw new Error(`\u8DEF\u5F84\u53C2\u6570 ${key} \u4E0D\u80FD\u4E3A\u7A7A: ${prefix}${path}`);
14
+ }
15
+ return encodeURIComponent(String(raw));
16
+ }) : path;
17
+ return `${prefix}${resolved}`;
18
+ }
19
+ var BaseResource = class {
20
+ constructor(client, prefix) {
21
+ __publicField(this, "client", client);
22
+ __publicField(this, "prefix", prefix);
23
+ }
24
+ /**
25
+ * 拼接完整请求路径:网关前缀 + OpenAPI path,并替换 `{var}` 路径参数。
26
+ *
27
+ * @param path OpenAPI path(含 `{var}` 占位符)
28
+ * @param pathVars 路径参数值(做 encodeURIComponent 处理)
29
+ */
30
+ url(path, pathVars) {
31
+ return resolveResourceUrl(this.prefix, path, pathVars);
32
+ }
33
+ };
34
+
35
+ // src/resources/lcdp-catalog.ts
36
+ var LcdpCatalogResource = class extends BaseResource {
37
+ listSchemas(id, options) {
38
+ return this.client.get(
39
+ this.url("/lcdp/data-sources/{id}/catalog/schemas", { id }),
40
+ void 0,
41
+ options
42
+ );
43
+ }
44
+ listTables(id, query, options) {
45
+ return this.client.get(
46
+ this.url("/lcdp/data-sources/{id}/catalog/tables", { id }),
47
+ query,
48
+ options
49
+ );
50
+ }
51
+ listColumns(id, tableName, query, options) {
52
+ return this.client.get(
53
+ this.url("/lcdp/data-sources/{id}/catalog/tables/{tableName}/columns", { id, tableName }),
54
+ query,
55
+ options
56
+ );
57
+ }
58
+ importTable(id, body, options) {
59
+ return this.client.post(
60
+ this.url("/lcdp/data-sources/{id}/catalog/import-table", { id }),
61
+ body,
62
+ options
63
+ );
64
+ }
65
+ };
66
+
67
+ // src/resources/lcdp-data.ts
68
+ var LcdpDataResource = class extends BaseResource {
69
+ page(id, body, options) {
70
+ return this.client.post(
71
+ this.url("/lcdp/data-sources/{id}/data/query", { id }),
72
+ body,
73
+ options
74
+ );
75
+ }
76
+ insert(id, body, options) {
77
+ return this.client.post(
78
+ this.url("/lcdp/data-sources/{id}/data/insert", { id }),
79
+ body,
80
+ options
81
+ );
82
+ }
83
+ update(id, body, options) {
84
+ return this.client.post(
85
+ this.url("/lcdp/data-sources/{id}/data/update", { id }),
86
+ body,
87
+ options
88
+ );
89
+ }
90
+ delete(id, body, options) {
91
+ return this.client.post(
92
+ this.url("/lcdp/data-sources/{id}/data/delete", { id }),
93
+ body,
94
+ options
95
+ );
96
+ }
97
+ };
98
+
99
+ // src/resources/lcdp-data-source.ts
100
+ var LcdpDataSourceResource = class extends BaseResource {
101
+ page(body, options) {
102
+ return this.client.post(this.url("/lcdp/data-sources/page"), body, options);
103
+ }
104
+ get(id, options) {
105
+ return this.client.get(this.url("/lcdp/data-sources/query/{id}", { id }), void 0, options);
106
+ }
107
+ add(body, options) {
108
+ return this.client.post(this.url("/lcdp/data-sources/add"), body, options);
109
+ }
110
+ update(id, body, options) {
111
+ return this.client.post(this.url("/lcdp/data-sources/update/{id}", { id }), body, options);
112
+ }
113
+ delete(id, options) {
114
+ return this.client.get(this.url("/lcdp/data-sources/delete/{id}", { id }), void 0, options);
115
+ }
116
+ test(body, options) {
117
+ return this.client.post(this.url("/lcdp/data-sources/test"), body, options);
118
+ }
119
+ };
120
+
121
+ // src/resources/lcdp-ddl.ts
122
+ var LcdpDdlResource = class extends BaseResource {
123
+ preview(id, body, options) {
124
+ return this.client.post(
125
+ this.url("/lcdp/data-sources/{id}/ddl/preview", { id }),
126
+ body,
127
+ options
128
+ );
129
+ }
130
+ createTable(id, body, options) {
131
+ return this.client.post(
132
+ this.url("/lcdp/data-sources/{id}/ddl/create-table", { id }),
133
+ body,
134
+ options
135
+ );
136
+ }
137
+ alterTable(id, body, options) {
138
+ return this.client.post(
139
+ this.url("/lcdp/data-sources/{id}/ddl/alter-table", { id }),
140
+ body,
141
+ options
142
+ );
143
+ }
144
+ dropTable(id, body, options) {
145
+ return this.client.post(
146
+ this.url("/lcdp/data-sources/{id}/ddl/drop-table", { id }),
147
+ body,
148
+ options
149
+ );
150
+ }
151
+ };
152
+
153
+ // src/resources/lcdp-form-def.ts
154
+ var LcdpFormDefResource = class extends BaseResource {
155
+ page(body, options) {
156
+ return this.client.post(this.url("/lcdp/form-defs/page"), body, options);
157
+ }
158
+ get(id, options) {
159
+ return this.client.get(this.url("/lcdp/form-defs/query/{id}", { id }), void 0, options);
160
+ }
161
+ validate(ir, options) {
162
+ return this.client.post(this.url("/lcdp/form-defs/validate"), ir, options);
163
+ }
164
+ upsertDraft(body, options) {
165
+ return this.client.post(this.url("/lcdp/form-defs/draft"), body, options);
166
+ }
167
+ publish(id, options) {
168
+ return this.client.post(this.url("/lcdp/form-defs/{id}/publish", { id }), void 0, options);
169
+ }
170
+ preview(ir, query, options) {
171
+ return this.client.post(this.url("/lcdp/form-defs/preview"), ir, {
172
+ ...options,
173
+ params: query
174
+ });
175
+ }
176
+ };
177
+
178
+ // src/resources/lcdp-runtime.ts
179
+ var LcdpRuntimeResource = class extends BaseResource {
180
+ /**
181
+ * 列表列元数据
182
+ *
183
+ * @param formCode Runtime 稳定入口
184
+ */
185
+ getColumns(formCode, options) {
186
+ return this.client.get(
187
+ this.url("/lcdp/runtime/forms/{formCode}/columns", { formCode }),
188
+ void 0,
189
+ options
190
+ );
191
+ }
192
+ /**
193
+ * 查询字段与固定操作符
194
+ *
195
+ * @param formCode Runtime 稳定入口
196
+ */
197
+ getQuerySchema(formCode, options) {
198
+ return this.client.get(
199
+ this.url("/lcdp/runtime/forms/{formCode}/query-schema", { formCode }),
200
+ void 0,
201
+ options
202
+ );
203
+ }
204
+ /**
205
+ * create/update/view 表单 schema
206
+ *
207
+ * @param formCode Runtime 稳定入口
208
+ */
209
+ getFormSchema(formCode, options) {
210
+ return this.client.get(
211
+ this.url("/lcdp/runtime/forms/{formCode}/form-schema", { formCode }),
212
+ void 0,
213
+ options
214
+ );
215
+ }
216
+ /**
217
+ * 参数化分页
218
+ *
219
+ * @param formCode Runtime 稳定入口
220
+ */
221
+ page(formCode, body, options) {
222
+ return this.client.post(
223
+ this.url("/lcdp/runtime/forms/{formCode}/data/page", { formCode }),
224
+ body,
225
+ options
226
+ );
227
+ }
228
+ /**
229
+ * 详情
230
+ *
231
+ * @param formCode Runtime 稳定入口
232
+ * @param id 定义主键
233
+ */
234
+ get(formCode, id, options) {
235
+ return this.client.get(
236
+ this.url("/lcdp/runtime/forms/{formCode}/data/{id}", { formCode, id }),
237
+ void 0,
238
+ options
239
+ );
240
+ }
241
+ /**
242
+ * 创建
243
+ *
244
+ * @param formCode Runtime 稳定入口
245
+ */
246
+ create(formCode, body, options) {
247
+ return this.client.post(
248
+ this.url("/lcdp/runtime/forms/{formCode}/data", { formCode }),
249
+ body,
250
+ options
251
+ );
252
+ }
253
+ /**
254
+ * 部分更新(仓规收敛:POST .../data/update/{id},原 PATCH .../data/{id})
255
+ *
256
+ * @param formCode Runtime 稳定入口
257
+ * @param id 定义主键
258
+ */
259
+ update(formCode, id, body, options) {
260
+ return this.client.post(
261
+ this.url("/lcdp/runtime/forms/{formCode}/data/update/{id}", { formCode, id }),
262
+ body,
263
+ options
264
+ );
265
+ }
266
+ /**
267
+ * 删除(仓规收敛:GET .../data/delete/{id},原 DELETE .../data/{id};revision 保持 query)
268
+ *
269
+ * @param formCode Runtime 稳定入口
270
+ * @param id 定义主键
271
+ * @param query 可选 revision
272
+ */
273
+ delete(formCode, id, query, options) {
274
+ return this.client.get(
275
+ this.url("/lcdp/runtime/forms/{formCode}/data/delete/{id}", { formCode, id }),
276
+ query,
277
+ options
278
+ );
279
+ }
280
+ /**
281
+ * 查询异步激活状态
282
+ *
283
+ * @param formCode Runtime 稳定入口
284
+ */
285
+ getPublication(formCode, options) {
286
+ return this.client.get(
287
+ this.url("/lcdp/runtime/forms/{formCode}/publication", { formCode }),
288
+ void 0,
289
+ options
290
+ );
291
+ }
292
+ /**
293
+ * 停用运行投影,不改发布定义
294
+ *
295
+ * @param formCode Runtime 稳定入口
296
+ */
297
+ disable(formCode, options) {
298
+ return this.client.post(
299
+ this.url("/lcdp/runtime/forms/{formCode}/publication/disable", { formCode }),
300
+ void 0,
301
+ options
302
+ );
303
+ }
304
+ /**
305
+ * 按已发布字段查询平铺选项或树节点
306
+ *
307
+ * @param formCode Runtime 稳定入口
308
+ * @param field 字段名
309
+ */
310
+ queryOptions(formCode, field, body, options) {
311
+ return this.client.post(
312
+ this.url("/lcdp/runtime/forms/{formCode}/options/{field}/query", { formCode, field }),
313
+ body,
314
+ options
315
+ );
316
+ }
317
+ /**
318
+ * 批量解析已存值,用于列表/详情/表单回显
319
+ *
320
+ * @param formCode Runtime 稳定入口
321
+ * @param field 字段名
322
+ */
323
+ resolveOptions(formCode, field, body, options) {
324
+ return this.client.post(
325
+ this.url("/lcdp/runtime/forms/{formCode}/options/{field}/resolve", { formCode, field }),
326
+ body,
327
+ options
328
+ );
329
+ }
330
+ /**
331
+ * columns + querySchema + formSchema + 首屏 page
332
+ *
333
+ * @param formCode Runtime 稳定入口
334
+ */
335
+ bootstrap(formCode, body, options) {
336
+ return this.client.post(
337
+ this.url("/lcdp/runtime/forms/{formCode}/bootstrap", { formCode }),
338
+ body,
339
+ options
340
+ );
341
+ }
342
+ };
343
+
344
+ // src/resources/lcdp-table-def.ts
345
+ var LcdpTableDefResource = class extends BaseResource {
346
+ page(body, options) {
347
+ return this.client.post(this.url("/lcdp/table-defs/page"), body, options);
348
+ }
349
+ get(id, options) {
350
+ return this.client.get(this.url("/lcdp/table-defs/query/{id}", { id }), void 0, options);
351
+ }
352
+ validate(ir, options) {
353
+ return this.client.post(this.url("/lcdp/table-defs/validate"), ir, options);
354
+ }
355
+ upsertDraft(body, options) {
356
+ return this.client.post(this.url("/lcdp/table-defs/draft"), body, options);
357
+ }
358
+ publish(id, options) {
359
+ return this.client.post(this.url("/lcdp/table-defs/{id}/publish", { id }), void 0, options);
360
+ }
361
+ withdraw(id, options) {
362
+ return this.client.post(this.url("/lcdp/table-defs/withdraw/{id}", { id }), void 0, options);
363
+ }
364
+ enableRuntime(id, options) {
365
+ return this.client.post(
366
+ this.url("/lcdp/table-defs/{id}/enable-runtime", { id }),
367
+ void 0,
368
+ options
369
+ );
370
+ }
371
+ };
372
+
373
+ // src/resources/lcdp-view.ts
374
+ var LcdpViewResource = class extends BaseResource {
375
+ create(id, body, options) {
376
+ return this.client.post(
377
+ this.url("/lcdp/data-sources/{id}/views/create", { id }),
378
+ body,
379
+ options
380
+ );
381
+ }
382
+ drop(id, viewName, query, options) {
383
+ return this.client.get(
384
+ this.url("/lcdp/data-sources/{id}/views/delete/{viewName}", { id, viewName }),
385
+ query,
386
+ options
387
+ );
388
+ }
389
+ };
390
+
391
+ // src/index.ts
392
+ var LcdpClient = class {
393
+ constructor(client) {
394
+ /** 数据源登记与只读 catalog / 导入 TableDef */
395
+ __publicField(this, "lcdpDataSource");
396
+ /** 只读 catalog / 导入 TableDef */
397
+ __publicField(this, "lcdpCatalog");
398
+ /** TableDef 列表、草稿、发布/撤回与 Runtime 开关 */
399
+ __publicField(this, "lcdpTableDef");
400
+ /** FormDef 列表与设计器接线 */
401
+ __publicField(this, "lcdpFormDef");
402
+ /** Runtime(13 个 operationId;MySQL + platform 门已开) */
403
+ __publicField(this, "lcdpRuntime");
404
+ /** 表数据浏览与主键行编辑(P2.2) */
405
+ __publicField(this, "lcdpData");
406
+ /** 结构化 DDL(P2.3;preview/execute 两步闭环) */
407
+ __publicField(this, "lcdpDdl");
408
+ /** 视图管理(P2.4;SELECT 白名单校验) */
409
+ __publicField(this, "lcdpView");
410
+ this.lcdpDataSource = new LcdpDataSourceResource(client, LCDP_PREFIX);
411
+ this.lcdpCatalog = new LcdpCatalogResource(client, LCDP_PREFIX);
412
+ this.lcdpTableDef = new LcdpTableDefResource(client, LCDP_PREFIX);
413
+ this.lcdpFormDef = new LcdpFormDefResource(client, LCDP_PREFIX);
414
+ this.lcdpRuntime = new LcdpRuntimeResource(client, LCDP_PREFIX);
415
+ this.lcdpData = new LcdpDataResource(client, LCDP_PREFIX);
416
+ this.lcdpDdl = new LcdpDdlResource(client, LCDP_PREFIX);
417
+ this.lcdpView = new LcdpViewResource(client, LCDP_PREFIX);
418
+ }
419
+ };
420
+ function createLcdpClient(client) {
421
+ return new LcdpClient(client);
422
+ }
423
+ export {
424
+ LcdpCatalogResource,
425
+ LcdpClient,
426
+ LcdpDataResource,
427
+ LcdpDataSourceResource,
428
+ LcdpDdlResource,
429
+ LcdpFormDefResource,
430
+ LcdpRuntimeResource,
431
+ LcdpTableDefResource,
432
+ LcdpViewResource,
433
+ createLcdpClient
434
+ };
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@xdmp-open/sdk-lowcode",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "description": "XDMP platform LCDP SDK: data sources, catalog, table/form defs, runtime, data/DDL/views",
5
+ "license": "Apache-2.0",
6
+ "author": "Linkwith IoT",
7
+ "homepage": "https://www.npmjs.com/package/@xdmp-open/sdk-lowcode",
8
+ "keywords": [
9
+ "xdmp",
10
+ "lcdp",
11
+ "lowcode",
12
+ "sdk"
13
+ ],
14
+ "type": "module",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "LICENSE",
21
+ "CHANGELOG.md"
22
+ ],
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "sideEffects": false,
34
+ "dependencies": {
35
+ "@xdmp-open/sdk-core": "0.1.6"
36
+ },
37
+ "devDependencies": {
38
+ "axios": "^1.7",
39
+ "axios-mock-adapter": "^2"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup src/index.ts --format esm --dts",
43
+ "test": "vitest run --passWithNoTests",
44
+ "typecheck": "tsc --noEmit"
45
+ }
6
46
  }