@back23/promptly-sdk 2.1.0 → 2.2.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/README.md +103 -30
- package/dist/index.d.mts +108 -34
- package/dist/index.d.ts +108 -34
- package/dist/index.js +107 -45
- package/dist/index.mjs +107 -45
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,55 @@ const { data: posts } = await client.blog.list();
|
|
|
24
24
|
const products = await client.shop.listProducts();
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## v2.2.0 Changes
|
|
28
|
+
|
|
29
|
+
### Entity Definition CRUD
|
|
30
|
+
|
|
31
|
+
이제 API/SDK에서 직접 커스텀 엔티티 정의를 생성/수정/삭제할 수 있습니다.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// 엔티티 정의 생성
|
|
35
|
+
const entity = await client.entities.create({
|
|
36
|
+
name: '고객',
|
|
37
|
+
slug: 'customers', // optional, auto-generated from name
|
|
38
|
+
description: '고객 관리',
|
|
39
|
+
schema: {
|
|
40
|
+
fields: [
|
|
41
|
+
{ name: 'company', label: '회사명', type: 'text', required: true },
|
|
42
|
+
{ name: 'email', label: '이메일', type: 'email', required: true },
|
|
43
|
+
{ name: 'status', label: '상태', type: 'select', options: [
|
|
44
|
+
{ value: 'active', label: '활성' },
|
|
45
|
+
{ value: 'inactive', label: '비활성' }
|
|
46
|
+
]}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
icon: 'users'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// 엔티티 정의 조회
|
|
53
|
+
const entity = await client.entities.get('customers');
|
|
54
|
+
|
|
55
|
+
// 엔티티 정의 수정
|
|
56
|
+
await client.entities.update('customers', { name: '고객사' });
|
|
57
|
+
|
|
58
|
+
// 엔티티 정의 삭제 (레코드 있으면 force 필요)
|
|
59
|
+
await client.entities.delete('customers', true);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Record API Path Change
|
|
63
|
+
|
|
64
|
+
레코드 API 경로가 변경되었습니다:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// v2.1.0 이전
|
|
68
|
+
await client.entities.createRecord('customers', { data: { company: 'ACME' } });
|
|
69
|
+
|
|
70
|
+
// v2.2.0 이후 - data wrapper 불필요
|
|
71
|
+
await client.entities.createRecord('customers', { company: 'ACME' });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
27
76
|
## v2.0.0 Breaking Changes
|
|
28
77
|
|
|
29
78
|
### API Key Required
|
|
@@ -94,7 +143,7 @@ data.map(post => ...); // data is always an array
|
|
|
94
143
|
| **Forms** | list, get, submit | mySubmissions |
|
|
95
144
|
| **Auth** | login, register | logout, me, updateProfile |
|
|
96
145
|
| **Media** | - | upload, list, delete |
|
|
97
|
-
| **Entities** | list,
|
|
146
|
+
| **Entities** | list, get, listRecords, getRecord | create, update, delete, createRecord, updateRecord, deleteRecord |
|
|
98
147
|
| **Reservation** | getSettings, listServices, listStaff, getAvailableDates, getAvailableSlots | create, list, get, cancel |
|
|
99
148
|
|
|
100
149
|
## API Reference
|
|
@@ -477,60 +526,84 @@ const { data: mediaList, meta } = await client.media.list({
|
|
|
477
526
|
await client.media.delete(mediaId);
|
|
478
527
|
```
|
|
479
528
|
|
|
480
|
-
### Entities (커스텀 엔티티) -
|
|
529
|
+
### Entities (커스텀 엔티티) - 동적 데이터 구조
|
|
481
530
|
|
|
482
|
-
|
|
531
|
+
API/SDK에서 직접 엔티티 정의를 생성하고 데이터를 관리할 수 있습니다.
|
|
483
532
|
|
|
484
|
-
####
|
|
533
|
+
#### Entity Definition CRUD
|
|
485
534
|
|
|
486
535
|
```typescript
|
|
487
536
|
// 엔티티 목록 조회
|
|
488
537
|
const entities = await client.entities.list();
|
|
489
538
|
// Returns: CustomEntity[] (always an array)
|
|
490
539
|
|
|
491
|
-
// 엔티티
|
|
492
|
-
const
|
|
493
|
-
|
|
540
|
+
// 엔티티 정의 생성
|
|
541
|
+
const entity = await client.entities.create({
|
|
542
|
+
name: '고객',
|
|
543
|
+
slug: 'customers',
|
|
544
|
+
description: '고객 관리',
|
|
545
|
+
schema: {
|
|
546
|
+
fields: [
|
|
547
|
+
{ name: 'company', label: '회사명', type: 'text', required: true },
|
|
548
|
+
{ name: 'email', label: '이메일', type: 'email', required: true },
|
|
549
|
+
{ name: 'status', label: '상태', type: 'select', options: [
|
|
550
|
+
{ value: 'active', label: '활성' },
|
|
551
|
+
{ value: 'inactive', label: '비활성' }
|
|
552
|
+
]}
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
icon: 'users'
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
// 엔티티 정의 조회 (스키마 포함)
|
|
559
|
+
const entity = await client.entities.get('customers');
|
|
560
|
+
// Returns: CustomEntity (includes schema)
|
|
561
|
+
|
|
562
|
+
// 엔티티 정의 수정
|
|
563
|
+
await client.entities.update('customers', {
|
|
564
|
+
name: '고객사',
|
|
565
|
+
description: '고객사 관리'
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// 엔티티 정의 삭제 (레코드가 있으면 force 필요)
|
|
569
|
+
await client.entities.delete('customers'); // 레코드 없을 때
|
|
570
|
+
await client.entities.delete('customers', true); // 레코드 있어도 강제 삭제
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### Record CRUD
|
|
494
574
|
|
|
575
|
+
```typescript
|
|
495
576
|
// 레코드 목록 조회
|
|
496
|
-
const { data: customers, meta } = await client.entities.listRecords('
|
|
577
|
+
const { data: customers, meta } = await client.entities.listRecords('customers', {
|
|
497
578
|
page: 1,
|
|
498
579
|
per_page: 20,
|
|
499
|
-
|
|
580
|
+
search: 'ACME', // 검색
|
|
581
|
+
sort: 'company', // 정렬 필드
|
|
582
|
+
dir: 'asc', // 정렬 방향
|
|
583
|
+
filters: JSON.stringify({ status: 'active' }) // JSON 필터
|
|
500
584
|
});
|
|
501
585
|
// Returns: ListResponse<EntityRecord>
|
|
502
586
|
|
|
503
|
-
// 데이터 필드로 필터링
|
|
504
|
-
const { data: vipCustomers } = await client.entities.listRecords('customer', {
|
|
505
|
-
'data.tier': 'vip',
|
|
506
|
-
});
|
|
507
|
-
|
|
508
587
|
// 단일 레코드 조회
|
|
509
|
-
const customer = await client.entities.getRecord('
|
|
588
|
+
const customer = await client.entities.getRecord('customers', 1);
|
|
510
589
|
// Returns: EntityRecord
|
|
511
590
|
console.log(customer.data.company); // 'ABC Corp'
|
|
512
|
-
```
|
|
513
591
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const newCustomer = await client.entities.createRecord('customer', {
|
|
519
|
-
data: {
|
|
520
|
-
company: 'ABC Corp',
|
|
521
|
-
email: 'contact@abc.com',
|
|
522
|
-
tier: 'standard',
|
|
523
|
-
},
|
|
592
|
+
// 레코드 생성 (스키마 필드 직접 전달)
|
|
593
|
+
const newCustomer = await client.entities.createRecord('customers', {
|
|
594
|
+
company: 'ABC Corp',
|
|
595
|
+
email: 'contact@abc.com',
|
|
524
596
|
status: 'active',
|
|
525
597
|
});
|
|
526
598
|
|
|
527
|
-
// 레코드 수정
|
|
528
|
-
await client.entities.updateRecord('
|
|
529
|
-
|
|
599
|
+
// 레코드 수정 (부분 업데이트 - 기존 데이터와 병합)
|
|
600
|
+
await client.entities.updateRecord('customers', 1, {
|
|
601
|
+
status: 'inactive',
|
|
602
|
+
email: 'new@abc.com'
|
|
530
603
|
});
|
|
531
604
|
|
|
532
605
|
// 레코드 삭제
|
|
533
|
-
await client.entities.deleteRecord('
|
|
606
|
+
await client.entities.deleteRecord('customers', 1);
|
|
534
607
|
```
|
|
535
608
|
|
|
536
609
|
#### TypeScript 타입 지원
|
package/dist/index.d.mts
CHANGED
|
@@ -621,6 +621,25 @@ interface UpdateEntityRecordData {
|
|
|
621
621
|
data?: Record<string, any>;
|
|
622
622
|
status?: 'active' | 'archived' | 'draft';
|
|
623
623
|
}
|
|
624
|
+
interface CreateEntityData {
|
|
625
|
+
name: string;
|
|
626
|
+
slug?: string;
|
|
627
|
+
description?: string;
|
|
628
|
+
schema: EntitySchema;
|
|
629
|
+
settings?: Record<string, any>;
|
|
630
|
+
icon?: string;
|
|
631
|
+
is_active?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface UpdateEntityData {
|
|
634
|
+
name?: string;
|
|
635
|
+
slug?: string;
|
|
636
|
+
description?: string;
|
|
637
|
+
schema?: EntitySchema;
|
|
638
|
+
settings?: Record<string, any>;
|
|
639
|
+
icon?: string;
|
|
640
|
+
is_active?: boolean;
|
|
641
|
+
sort_order?: number;
|
|
642
|
+
}
|
|
624
643
|
|
|
625
644
|
/**
|
|
626
645
|
* Reservation types for Promptly SDK
|
|
@@ -805,7 +824,7 @@ declare class HttpClient {
|
|
|
805
824
|
/**
|
|
806
825
|
* DELETE request
|
|
807
826
|
*/
|
|
808
|
-
delete<T>(endpoint: string): Promise<T>;
|
|
827
|
+
delete<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
809
828
|
/**
|
|
810
829
|
* Upload file
|
|
811
830
|
*/
|
|
@@ -1159,25 +1178,80 @@ declare class EntitiesResource {
|
|
|
1159
1178
|
private http;
|
|
1160
1179
|
constructor(http: HttpClient);
|
|
1161
1180
|
/**
|
|
1162
|
-
* List all
|
|
1163
|
-
* @returns Array of entities
|
|
1181
|
+
* List all custom entities
|
|
1182
|
+
* @returns Array of entities
|
|
1164
1183
|
*
|
|
1165
1184
|
* @example
|
|
1166
1185
|
* ```typescript
|
|
1167
1186
|
* const entities = await client.entities.list();
|
|
1168
|
-
* // [{ id: 1, name: 'Customer', slug: 'customer', ... }]
|
|
1187
|
+
* // [{ id: 1, name: 'Customer', slug: 'customer', records_count: 150, ... }]
|
|
1169
1188
|
* ```
|
|
1170
1189
|
*/
|
|
1171
1190
|
list(): Promise<CustomEntity[]>;
|
|
1172
1191
|
/**
|
|
1173
|
-
*
|
|
1192
|
+
* Create a new entity definition
|
|
1174
1193
|
*
|
|
1175
1194
|
* @example
|
|
1176
1195
|
* ```typescript
|
|
1177
|
-
* const
|
|
1178
|
-
*
|
|
1196
|
+
* const entity = await client.entities.create({
|
|
1197
|
+
* name: '고객',
|
|
1198
|
+
* slug: 'customers', // optional, auto-generated from name
|
|
1199
|
+
* description: '고객 관리',
|
|
1200
|
+
* schema: {
|
|
1201
|
+
* fields: [
|
|
1202
|
+
* { name: 'company', label: '회사명', type: 'text', required: true },
|
|
1203
|
+
* { name: 'email', label: '이메일', type: 'email', required: true },
|
|
1204
|
+
* { name: 'status', label: '상태', type: 'select', options: [
|
|
1205
|
+
* { value: 'active', label: '활성' },
|
|
1206
|
+
* { value: 'inactive', label: '비활성' }
|
|
1207
|
+
* ]}
|
|
1208
|
+
* ]
|
|
1209
|
+
* },
|
|
1210
|
+
* icon: 'users'
|
|
1211
|
+
* });
|
|
1179
1212
|
* ```
|
|
1180
1213
|
*/
|
|
1214
|
+
create(data: CreateEntityData): Promise<CustomEntity>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Get entity definition by slug (includes schema)
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```typescript
|
|
1220
|
+
* const entity = await client.entities.get('customers');
|
|
1221
|
+
* console.log(entity.schema.fields);
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
get(slug: string): Promise<CustomEntity>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Update an entity definition
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```typescript
|
|
1230
|
+
* const updated = await client.entities.update('customers', {
|
|
1231
|
+
* name: '고객사',
|
|
1232
|
+
* description: '고객사 관리'
|
|
1233
|
+
* });
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
update(slug: string, data: UpdateEntityData): Promise<CustomEntity>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Delete an entity definition
|
|
1239
|
+
* If entity has records, use force=true to delete anyway
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```typescript
|
|
1243
|
+
* // Will fail if entity has records
|
|
1244
|
+
* await client.entities.delete('customers');
|
|
1245
|
+
*
|
|
1246
|
+
* // Force delete with all records
|
|
1247
|
+
* await client.entities.delete('customers', true);
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
delete(slug: string, force?: boolean): Promise<void>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Get entity schema (convenience method)
|
|
1253
|
+
* @deprecated Use get(slug) instead - it includes schema
|
|
1254
|
+
*/
|
|
1181
1255
|
getSchema(slug: string): Promise<EntitySchema>;
|
|
1182
1256
|
/**
|
|
1183
1257
|
* List records for an entity
|
|
@@ -1186,18 +1260,20 @@ declare class EntitiesResource {
|
|
|
1186
1260
|
* @example
|
|
1187
1261
|
* ```typescript
|
|
1188
1262
|
* // Basic listing
|
|
1189
|
-
* const customers = await client.entities.listRecords('
|
|
1263
|
+
* const customers = await client.entities.listRecords('customers');
|
|
1190
1264
|
*
|
|
1191
|
-
* // With pagination
|
|
1192
|
-
* const customers = await client.entities.listRecords('
|
|
1265
|
+
* // With pagination and search
|
|
1266
|
+
* const customers = await client.entities.listRecords('customers', {
|
|
1193
1267
|
* page: 1,
|
|
1194
1268
|
* per_page: 20,
|
|
1195
|
-
*
|
|
1269
|
+
* search: 'ACME',
|
|
1270
|
+
* sort: 'company',
|
|
1271
|
+
* dir: 'asc'
|
|
1196
1272
|
* });
|
|
1197
1273
|
*
|
|
1198
|
-
* // With filtering
|
|
1199
|
-
* const vipCustomers = await client.entities.listRecords('
|
|
1200
|
-
*
|
|
1274
|
+
* // With filtering
|
|
1275
|
+
* const vipCustomers = await client.entities.listRecords('customers', {
|
|
1276
|
+
* filters: JSON.stringify({ tier: 'vip' })
|
|
1201
1277
|
* });
|
|
1202
1278
|
* ```
|
|
1203
1279
|
*/
|
|
@@ -1207,46 +1283,44 @@ declare class EntitiesResource {
|
|
|
1207
1283
|
*
|
|
1208
1284
|
* @example
|
|
1209
1285
|
* ```typescript
|
|
1210
|
-
* const customer = await client.entities.getRecord('
|
|
1286
|
+
* const customer = await client.entities.getRecord('customers', 1);
|
|
1211
1287
|
* console.log(customer.data.company); // 'ABC Corp'
|
|
1212
1288
|
* ```
|
|
1213
1289
|
*/
|
|
1214
1290
|
getRecord(slug: string, id: number): Promise<EntityRecord>;
|
|
1215
1291
|
/**
|
|
1216
1292
|
* Create a new record
|
|
1293
|
+
* Request body fields are defined by entity schema
|
|
1217
1294
|
*
|
|
1218
1295
|
* @example
|
|
1219
1296
|
* ```typescript
|
|
1220
|
-
* const newCustomer = await client.entities.createRecord('
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
* tier: 'standard',
|
|
1225
|
-
* },
|
|
1226
|
-
* status: 'active',
|
|
1297
|
+
* const newCustomer = await client.entities.createRecord('customers', {
|
|
1298
|
+
* company: 'ABC Corp',
|
|
1299
|
+
* email: 'contact@abc.com',
|
|
1300
|
+
* tier: 'standard',
|
|
1227
1301
|
* });
|
|
1228
1302
|
* ```
|
|
1229
1303
|
*/
|
|
1230
|
-
createRecord(slug: string, data:
|
|
1304
|
+
createRecord(slug: string, data: Record<string, any>): Promise<EntityRecord>;
|
|
1231
1305
|
/**
|
|
1232
1306
|
* Update a record
|
|
1307
|
+
* Only provided fields will be updated, existing data is preserved
|
|
1233
1308
|
*
|
|
1234
1309
|
* @example
|
|
1235
1310
|
* ```typescript
|
|
1236
|
-
* const updated = await client.entities.updateRecord('
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
* },
|
|
1311
|
+
* const updated = await client.entities.updateRecord('customers', 1, {
|
|
1312
|
+
* tier: 'vip',
|
|
1313
|
+
* email: 'new@abc.com'
|
|
1240
1314
|
* });
|
|
1241
1315
|
* ```
|
|
1242
1316
|
*/
|
|
1243
|
-
updateRecord(slug: string, id: number, data:
|
|
1317
|
+
updateRecord(slug: string, id: number, data: Record<string, any>): Promise<EntityRecord>;
|
|
1244
1318
|
/**
|
|
1245
1319
|
* Delete a record
|
|
1246
1320
|
*
|
|
1247
1321
|
* @example
|
|
1248
1322
|
* ```typescript
|
|
1249
|
-
* await client.entities.deleteRecord('
|
|
1323
|
+
* await client.entities.deleteRecord('customers', 1);
|
|
1250
1324
|
* ```
|
|
1251
1325
|
*/
|
|
1252
1326
|
deleteRecord(slug: string, id: number): Promise<void>;
|
|
@@ -1255,7 +1329,7 @@ declare class EntitiesResource {
|
|
|
1255
1329
|
*
|
|
1256
1330
|
* @example
|
|
1257
1331
|
* ```typescript
|
|
1258
|
-
* const record = await client.entities.getRecord('
|
|
1332
|
+
* const record = await client.entities.getRecord('customers', 1);
|
|
1259
1333
|
* const company = client.entities.getValue(record, 'company');
|
|
1260
1334
|
* ```
|
|
1261
1335
|
*/
|
|
@@ -1271,7 +1345,7 @@ declare class EntitiesResource {
|
|
|
1271
1345
|
* tier: 'standard' | 'vip';
|
|
1272
1346
|
* }
|
|
1273
1347
|
*
|
|
1274
|
-
* const customers = client.entities.typed<Customer>('
|
|
1348
|
+
* const customers = client.entities.typed<Customer>('customers');
|
|
1275
1349
|
* const list = await customers.list(); // Typed records
|
|
1276
1350
|
* const record = await customers.get(1);
|
|
1277
1351
|
* console.log(record.data.company); // TypeScript knows this is string
|
|
@@ -1287,10 +1361,10 @@ declare class EntitiesResource {
|
|
|
1287
1361
|
get: (id: number) => Promise<Omit<EntityRecord, "data"> & {
|
|
1288
1362
|
data: T;
|
|
1289
1363
|
}>;
|
|
1290
|
-
create: (data: T
|
|
1364
|
+
create: (data: T) => Promise<Omit<EntityRecord, "data"> & {
|
|
1291
1365
|
data: T;
|
|
1292
1366
|
}>;
|
|
1293
|
-
update: (id: number, data: Partial<T
|
|
1367
|
+
update: (id: number, data: Partial<T>) => Promise<Omit<EntityRecord, "data"> & {
|
|
1294
1368
|
data: T;
|
|
1295
1369
|
}>;
|
|
1296
1370
|
delete: (id: number) => Promise<void>;
|
|
@@ -1448,4 +1522,4 @@ declare class Promptly {
|
|
|
1448
1522
|
getApiKey(): string | null;
|
|
1449
1523
|
}
|
|
1450
1524
|
|
|
1451
|
-
export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type AvailableDatesParams, type AvailableSlotsParams, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CreateReservationData, type CreateReservationResult, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type ListResponse, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type PaginationMeta, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type Reservation, type ReservationListParams, type ReservationService, type ReservationSettings, type ReservationSlot, type ReservationStaff, type ReservationStaffSummary, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
|
1525
|
+
export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type AvailableDatesParams, type AvailableSlotsParams, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CreateReservationData, type CreateReservationResult, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type ListResponse, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type PaginationMeta, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type Reservation, type ReservationListParams, type ReservationService, type ReservationSettings, type ReservationSlot, type ReservationStaff, type ReservationStaffSummary, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -621,6 +621,25 @@ interface UpdateEntityRecordData {
|
|
|
621
621
|
data?: Record<string, any>;
|
|
622
622
|
status?: 'active' | 'archived' | 'draft';
|
|
623
623
|
}
|
|
624
|
+
interface CreateEntityData {
|
|
625
|
+
name: string;
|
|
626
|
+
slug?: string;
|
|
627
|
+
description?: string;
|
|
628
|
+
schema: EntitySchema;
|
|
629
|
+
settings?: Record<string, any>;
|
|
630
|
+
icon?: string;
|
|
631
|
+
is_active?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface UpdateEntityData {
|
|
634
|
+
name?: string;
|
|
635
|
+
slug?: string;
|
|
636
|
+
description?: string;
|
|
637
|
+
schema?: EntitySchema;
|
|
638
|
+
settings?: Record<string, any>;
|
|
639
|
+
icon?: string;
|
|
640
|
+
is_active?: boolean;
|
|
641
|
+
sort_order?: number;
|
|
642
|
+
}
|
|
624
643
|
|
|
625
644
|
/**
|
|
626
645
|
* Reservation types for Promptly SDK
|
|
@@ -805,7 +824,7 @@ declare class HttpClient {
|
|
|
805
824
|
/**
|
|
806
825
|
* DELETE request
|
|
807
826
|
*/
|
|
808
|
-
delete<T>(endpoint: string): Promise<T>;
|
|
827
|
+
delete<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
|
|
809
828
|
/**
|
|
810
829
|
* Upload file
|
|
811
830
|
*/
|
|
@@ -1159,25 +1178,80 @@ declare class EntitiesResource {
|
|
|
1159
1178
|
private http;
|
|
1160
1179
|
constructor(http: HttpClient);
|
|
1161
1180
|
/**
|
|
1162
|
-
* List all
|
|
1163
|
-
* @returns Array of entities
|
|
1181
|
+
* List all custom entities
|
|
1182
|
+
* @returns Array of entities
|
|
1164
1183
|
*
|
|
1165
1184
|
* @example
|
|
1166
1185
|
* ```typescript
|
|
1167
1186
|
* const entities = await client.entities.list();
|
|
1168
|
-
* // [{ id: 1, name: 'Customer', slug: 'customer', ... }]
|
|
1187
|
+
* // [{ id: 1, name: 'Customer', slug: 'customer', records_count: 150, ... }]
|
|
1169
1188
|
* ```
|
|
1170
1189
|
*/
|
|
1171
1190
|
list(): Promise<CustomEntity[]>;
|
|
1172
1191
|
/**
|
|
1173
|
-
*
|
|
1192
|
+
* Create a new entity definition
|
|
1174
1193
|
*
|
|
1175
1194
|
* @example
|
|
1176
1195
|
* ```typescript
|
|
1177
|
-
* const
|
|
1178
|
-
*
|
|
1196
|
+
* const entity = await client.entities.create({
|
|
1197
|
+
* name: '고객',
|
|
1198
|
+
* slug: 'customers', // optional, auto-generated from name
|
|
1199
|
+
* description: '고객 관리',
|
|
1200
|
+
* schema: {
|
|
1201
|
+
* fields: [
|
|
1202
|
+
* { name: 'company', label: '회사명', type: 'text', required: true },
|
|
1203
|
+
* { name: 'email', label: '이메일', type: 'email', required: true },
|
|
1204
|
+
* { name: 'status', label: '상태', type: 'select', options: [
|
|
1205
|
+
* { value: 'active', label: '활성' },
|
|
1206
|
+
* { value: 'inactive', label: '비활성' }
|
|
1207
|
+
* ]}
|
|
1208
|
+
* ]
|
|
1209
|
+
* },
|
|
1210
|
+
* icon: 'users'
|
|
1211
|
+
* });
|
|
1179
1212
|
* ```
|
|
1180
1213
|
*/
|
|
1214
|
+
create(data: CreateEntityData): Promise<CustomEntity>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Get entity definition by slug (includes schema)
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```typescript
|
|
1220
|
+
* const entity = await client.entities.get('customers');
|
|
1221
|
+
* console.log(entity.schema.fields);
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
get(slug: string): Promise<CustomEntity>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Update an entity definition
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```typescript
|
|
1230
|
+
* const updated = await client.entities.update('customers', {
|
|
1231
|
+
* name: '고객사',
|
|
1232
|
+
* description: '고객사 관리'
|
|
1233
|
+
* });
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
update(slug: string, data: UpdateEntityData): Promise<CustomEntity>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Delete an entity definition
|
|
1239
|
+
* If entity has records, use force=true to delete anyway
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```typescript
|
|
1243
|
+
* // Will fail if entity has records
|
|
1244
|
+
* await client.entities.delete('customers');
|
|
1245
|
+
*
|
|
1246
|
+
* // Force delete with all records
|
|
1247
|
+
* await client.entities.delete('customers', true);
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
delete(slug: string, force?: boolean): Promise<void>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Get entity schema (convenience method)
|
|
1253
|
+
* @deprecated Use get(slug) instead - it includes schema
|
|
1254
|
+
*/
|
|
1181
1255
|
getSchema(slug: string): Promise<EntitySchema>;
|
|
1182
1256
|
/**
|
|
1183
1257
|
* List records for an entity
|
|
@@ -1186,18 +1260,20 @@ declare class EntitiesResource {
|
|
|
1186
1260
|
* @example
|
|
1187
1261
|
* ```typescript
|
|
1188
1262
|
* // Basic listing
|
|
1189
|
-
* const customers = await client.entities.listRecords('
|
|
1263
|
+
* const customers = await client.entities.listRecords('customers');
|
|
1190
1264
|
*
|
|
1191
|
-
* // With pagination
|
|
1192
|
-
* const customers = await client.entities.listRecords('
|
|
1265
|
+
* // With pagination and search
|
|
1266
|
+
* const customers = await client.entities.listRecords('customers', {
|
|
1193
1267
|
* page: 1,
|
|
1194
1268
|
* per_page: 20,
|
|
1195
|
-
*
|
|
1269
|
+
* search: 'ACME',
|
|
1270
|
+
* sort: 'company',
|
|
1271
|
+
* dir: 'asc'
|
|
1196
1272
|
* });
|
|
1197
1273
|
*
|
|
1198
|
-
* // With filtering
|
|
1199
|
-
* const vipCustomers = await client.entities.listRecords('
|
|
1200
|
-
*
|
|
1274
|
+
* // With filtering
|
|
1275
|
+
* const vipCustomers = await client.entities.listRecords('customers', {
|
|
1276
|
+
* filters: JSON.stringify({ tier: 'vip' })
|
|
1201
1277
|
* });
|
|
1202
1278
|
* ```
|
|
1203
1279
|
*/
|
|
@@ -1207,46 +1283,44 @@ declare class EntitiesResource {
|
|
|
1207
1283
|
*
|
|
1208
1284
|
* @example
|
|
1209
1285
|
* ```typescript
|
|
1210
|
-
* const customer = await client.entities.getRecord('
|
|
1286
|
+
* const customer = await client.entities.getRecord('customers', 1);
|
|
1211
1287
|
* console.log(customer.data.company); // 'ABC Corp'
|
|
1212
1288
|
* ```
|
|
1213
1289
|
*/
|
|
1214
1290
|
getRecord(slug: string, id: number): Promise<EntityRecord>;
|
|
1215
1291
|
/**
|
|
1216
1292
|
* Create a new record
|
|
1293
|
+
* Request body fields are defined by entity schema
|
|
1217
1294
|
*
|
|
1218
1295
|
* @example
|
|
1219
1296
|
* ```typescript
|
|
1220
|
-
* const newCustomer = await client.entities.createRecord('
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
* tier: 'standard',
|
|
1225
|
-
* },
|
|
1226
|
-
* status: 'active',
|
|
1297
|
+
* const newCustomer = await client.entities.createRecord('customers', {
|
|
1298
|
+
* company: 'ABC Corp',
|
|
1299
|
+
* email: 'contact@abc.com',
|
|
1300
|
+
* tier: 'standard',
|
|
1227
1301
|
* });
|
|
1228
1302
|
* ```
|
|
1229
1303
|
*/
|
|
1230
|
-
createRecord(slug: string, data:
|
|
1304
|
+
createRecord(slug: string, data: Record<string, any>): Promise<EntityRecord>;
|
|
1231
1305
|
/**
|
|
1232
1306
|
* Update a record
|
|
1307
|
+
* Only provided fields will be updated, existing data is preserved
|
|
1233
1308
|
*
|
|
1234
1309
|
* @example
|
|
1235
1310
|
* ```typescript
|
|
1236
|
-
* const updated = await client.entities.updateRecord('
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
* },
|
|
1311
|
+
* const updated = await client.entities.updateRecord('customers', 1, {
|
|
1312
|
+
* tier: 'vip',
|
|
1313
|
+
* email: 'new@abc.com'
|
|
1240
1314
|
* });
|
|
1241
1315
|
* ```
|
|
1242
1316
|
*/
|
|
1243
|
-
updateRecord(slug: string, id: number, data:
|
|
1317
|
+
updateRecord(slug: string, id: number, data: Record<string, any>): Promise<EntityRecord>;
|
|
1244
1318
|
/**
|
|
1245
1319
|
* Delete a record
|
|
1246
1320
|
*
|
|
1247
1321
|
* @example
|
|
1248
1322
|
* ```typescript
|
|
1249
|
-
* await client.entities.deleteRecord('
|
|
1323
|
+
* await client.entities.deleteRecord('customers', 1);
|
|
1250
1324
|
* ```
|
|
1251
1325
|
*/
|
|
1252
1326
|
deleteRecord(slug: string, id: number): Promise<void>;
|
|
@@ -1255,7 +1329,7 @@ declare class EntitiesResource {
|
|
|
1255
1329
|
*
|
|
1256
1330
|
* @example
|
|
1257
1331
|
* ```typescript
|
|
1258
|
-
* const record = await client.entities.getRecord('
|
|
1332
|
+
* const record = await client.entities.getRecord('customers', 1);
|
|
1259
1333
|
* const company = client.entities.getValue(record, 'company');
|
|
1260
1334
|
* ```
|
|
1261
1335
|
*/
|
|
@@ -1271,7 +1345,7 @@ declare class EntitiesResource {
|
|
|
1271
1345
|
* tier: 'standard' | 'vip';
|
|
1272
1346
|
* }
|
|
1273
1347
|
*
|
|
1274
|
-
* const customers = client.entities.typed<Customer>('
|
|
1348
|
+
* const customers = client.entities.typed<Customer>('customers');
|
|
1275
1349
|
* const list = await customers.list(); // Typed records
|
|
1276
1350
|
* const record = await customers.get(1);
|
|
1277
1351
|
* console.log(record.data.company); // TypeScript knows this is string
|
|
@@ -1287,10 +1361,10 @@ declare class EntitiesResource {
|
|
|
1287
1361
|
get: (id: number) => Promise<Omit<EntityRecord, "data"> & {
|
|
1288
1362
|
data: T;
|
|
1289
1363
|
}>;
|
|
1290
|
-
create: (data: T
|
|
1364
|
+
create: (data: T) => Promise<Omit<EntityRecord, "data"> & {
|
|
1291
1365
|
data: T;
|
|
1292
1366
|
}>;
|
|
1293
|
-
update: (id: number, data: Partial<T
|
|
1367
|
+
update: (id: number, data: Partial<T>) => Promise<Omit<EntityRecord, "data"> & {
|
|
1294
1368
|
data: T;
|
|
1295
1369
|
}>;
|
|
1296
1370
|
delete: (id: number) => Promise<void>;
|
|
@@ -1448,4 +1522,4 @@ declare class Promptly {
|
|
|
1448
1522
|
getApiKey(): string | null;
|
|
1449
1523
|
}
|
|
1450
1524
|
|
|
1451
|
-
export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type AvailableDatesParams, type AvailableSlotsParams, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CreateReservationData, type CreateReservationResult, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type ListResponse, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type PaginationMeta, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type Reservation, type ReservationListParams, type ReservationService, type ReservationSettings, type ReservationSlot, type ReservationStaff, type ReservationStaffSummary, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
|
1525
|
+
export { type AddToCartData, type ApiError, type ApiResponse, type ApplyCouponData, type AuthResponse, type AvailableDatesParams, type AvailableSlotsParams, type BlogListParams, type BlogPost, type Board, type BoardComment, type BoardListParams, type BoardPost, type BoardSettings, type Cart, type CartItem, type Coupon, type CouponType, type CouponValidation, type CreateCommentData, type CreateEntityData, type CreateEntityRecordData, type CreateOrderData, type CreatePostData, type CreateReservationData, type CreateReservationResult, type CustomEntity, type EntityField, type EntityListParams, type EntityRecord, type EntitySchema, type ForgotPasswordData, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormListParams, type FormSettings, type FormSubmission, type ListParams, type ListResponse, type LoginCredentials, type Media, type Member, type Order, type OrderItem, type OrderListParams, type OrderStatus, type PaginatedResponse, type PaginationMeta, type Payment, type PaymentCancelData, type PaymentConfirmData, type PaymentMethod, type PaymentReadyData, type PaymentStatus, type PostListParams, type Product, type ProductCategory, type ProductListParams, type ProductOption, type ProductOptionValue, type ProductStatus, type ProductVariant, Promptly, type PromptlyConfig, PromptlyError, type RegisterData, type Reservation, type ReservationListParams, type ReservationService, type ReservationSettings, type ReservationSlot, type ReservationStaff, type ReservationStaffSummary, type ResetPasswordData, type SocialAuthUrl, type SocialProvider, type SubmissionListParams, type SubmitFormData, type UpdateCartItemData, type UpdateCommentData, type UpdateEntityData, type UpdateEntityRecordData, type UpdatePostData, type UpdateProfileData, Promptly as default };
|
package/dist/index.js
CHANGED
|
@@ -212,8 +212,8 @@ var HttpClient = class {
|
|
|
212
212
|
/**
|
|
213
213
|
* DELETE request
|
|
214
214
|
*/
|
|
215
|
-
delete(endpoint) {
|
|
216
|
-
return this.request(endpoint, { method: "DELETE" });
|
|
215
|
+
delete(endpoint, params) {
|
|
216
|
+
return this.request(endpoint, { method: "DELETE", params });
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Upload file
|
|
@@ -804,16 +804,16 @@ var EntitiesResource = class {
|
|
|
804
804
|
this.http = http;
|
|
805
805
|
}
|
|
806
806
|
// ============================================
|
|
807
|
-
//
|
|
807
|
+
// Entity Definitions CRUD
|
|
808
808
|
// ============================================
|
|
809
809
|
/**
|
|
810
|
-
* List all
|
|
811
|
-
* @returns Array of entities
|
|
810
|
+
* List all custom entities
|
|
811
|
+
* @returns Array of entities
|
|
812
812
|
*
|
|
813
813
|
* @example
|
|
814
814
|
* ```typescript
|
|
815
815
|
* const entities = await client.entities.list();
|
|
816
|
-
* // [{ id: 1, name: 'Customer', slug: 'customer', ... }]
|
|
816
|
+
* // [{ id: 1, name: 'Customer', slug: 'customer', records_count: 150, ... }]
|
|
817
817
|
* ```
|
|
818
818
|
*/
|
|
819
819
|
async list() {
|
|
@@ -821,19 +821,84 @@ var EntitiesResource = class {
|
|
|
821
821
|
return response.data;
|
|
822
822
|
}
|
|
823
823
|
/**
|
|
824
|
-
*
|
|
824
|
+
* Create a new entity definition
|
|
825
825
|
*
|
|
826
826
|
* @example
|
|
827
827
|
* ```typescript
|
|
828
|
-
* const
|
|
829
|
-
*
|
|
828
|
+
* const entity = await client.entities.create({
|
|
829
|
+
* name: '고객',
|
|
830
|
+
* slug: 'customers', // optional, auto-generated from name
|
|
831
|
+
* description: '고객 관리',
|
|
832
|
+
* schema: {
|
|
833
|
+
* fields: [
|
|
834
|
+
* { name: 'company', label: '회사명', type: 'text', required: true },
|
|
835
|
+
* { name: 'email', label: '이메일', type: 'email', required: true },
|
|
836
|
+
* { name: 'status', label: '상태', type: 'select', options: [
|
|
837
|
+
* { value: 'active', label: '활성' },
|
|
838
|
+
* { value: 'inactive', label: '비활성' }
|
|
839
|
+
* ]}
|
|
840
|
+
* ]
|
|
841
|
+
* },
|
|
842
|
+
* icon: 'users'
|
|
843
|
+
* });
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
async create(data) {
|
|
847
|
+
return this.http.post("/entities", data);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Get entity definition by slug (includes schema)
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* ```typescript
|
|
854
|
+
* const entity = await client.entities.get('customers');
|
|
855
|
+
* console.log(entity.schema.fields);
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
async get(slug) {
|
|
859
|
+
return this.http.get(`/entities/${slug}`);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Update an entity definition
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* ```typescript
|
|
866
|
+
* const updated = await client.entities.update('customers', {
|
|
867
|
+
* name: '고객사',
|
|
868
|
+
* description: '고객사 관리'
|
|
869
|
+
* });
|
|
830
870
|
* ```
|
|
831
871
|
*/
|
|
872
|
+
async update(slug, data) {
|
|
873
|
+
return this.http.put(`/entities/${slug}`, data);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Delete an entity definition
|
|
877
|
+
* If entity has records, use force=true to delete anyway
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```typescript
|
|
881
|
+
* // Will fail if entity has records
|
|
882
|
+
* await client.entities.delete('customers');
|
|
883
|
+
*
|
|
884
|
+
* // Force delete with all records
|
|
885
|
+
* await client.entities.delete('customers', true);
|
|
886
|
+
* ```
|
|
887
|
+
*/
|
|
888
|
+
async delete(slug, force = false) {
|
|
889
|
+
const params = force ? { force: "true" } : void 0;
|
|
890
|
+
return this.http.delete(`/entities/${slug}`, params);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Get entity schema (convenience method)
|
|
894
|
+
* @deprecated Use get(slug) instead - it includes schema
|
|
895
|
+
*/
|
|
832
896
|
async getSchema(slug) {
|
|
833
|
-
|
|
897
|
+
const entity = await this.get(slug);
|
|
898
|
+
return entity.schema;
|
|
834
899
|
}
|
|
835
900
|
// ============================================
|
|
836
|
-
// Records
|
|
901
|
+
// Records CRUD
|
|
837
902
|
// ============================================
|
|
838
903
|
/**
|
|
839
904
|
* List records for an entity
|
|
@@ -842,82 +907,79 @@ var EntitiesResource = class {
|
|
|
842
907
|
* @example
|
|
843
908
|
* ```typescript
|
|
844
909
|
* // Basic listing
|
|
845
|
-
* const customers = await client.entities.listRecords('
|
|
910
|
+
* const customers = await client.entities.listRecords('customers');
|
|
846
911
|
*
|
|
847
|
-
* // With pagination
|
|
848
|
-
* const customers = await client.entities.listRecords('
|
|
912
|
+
* // With pagination and search
|
|
913
|
+
* const customers = await client.entities.listRecords('customers', {
|
|
849
914
|
* page: 1,
|
|
850
915
|
* per_page: 20,
|
|
851
|
-
*
|
|
916
|
+
* search: 'ACME',
|
|
917
|
+
* sort: 'company',
|
|
918
|
+
* dir: 'asc'
|
|
852
919
|
* });
|
|
853
920
|
*
|
|
854
|
-
* // With filtering
|
|
855
|
-
* const vipCustomers = await client.entities.listRecords('
|
|
856
|
-
*
|
|
921
|
+
* // With filtering
|
|
922
|
+
* const vipCustomers = await client.entities.listRecords('customers', {
|
|
923
|
+
* filters: JSON.stringify({ tier: 'vip' })
|
|
857
924
|
* });
|
|
858
925
|
* ```
|
|
859
926
|
*/
|
|
860
927
|
async listRecords(slug, params) {
|
|
861
|
-
return this.http.getList(`/entities/${slug}`, params);
|
|
928
|
+
return this.http.getList(`/entities/${slug}/records`, params);
|
|
862
929
|
}
|
|
863
930
|
/**
|
|
864
931
|
* Get a single record by ID
|
|
865
932
|
*
|
|
866
933
|
* @example
|
|
867
934
|
* ```typescript
|
|
868
|
-
* const customer = await client.entities.getRecord('
|
|
935
|
+
* const customer = await client.entities.getRecord('customers', 1);
|
|
869
936
|
* console.log(customer.data.company); // 'ABC Corp'
|
|
870
937
|
* ```
|
|
871
938
|
*/
|
|
872
939
|
async getRecord(slug, id) {
|
|
873
|
-
return this.http.get(`/entities/${slug}/${id}`);
|
|
940
|
+
return this.http.get(`/entities/${slug}/records/${id}`);
|
|
874
941
|
}
|
|
875
|
-
// ============================================
|
|
876
|
-
// Records (Protected - requires auth)
|
|
877
|
-
// ============================================
|
|
878
942
|
/**
|
|
879
943
|
* Create a new record
|
|
944
|
+
* Request body fields are defined by entity schema
|
|
880
945
|
*
|
|
881
946
|
* @example
|
|
882
947
|
* ```typescript
|
|
883
|
-
* const newCustomer = await client.entities.createRecord('
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
887
|
-
* tier: 'standard',
|
|
888
|
-
* },
|
|
889
|
-
* status: 'active',
|
|
948
|
+
* const newCustomer = await client.entities.createRecord('customers', {
|
|
949
|
+
* company: 'ABC Corp',
|
|
950
|
+
* email: 'contact@abc.com',
|
|
951
|
+
* tier: 'standard',
|
|
890
952
|
* });
|
|
891
953
|
* ```
|
|
892
954
|
*/
|
|
893
955
|
async createRecord(slug, data) {
|
|
894
|
-
return this.http.post(`/entities/${slug}`, data);
|
|
956
|
+
return this.http.post(`/entities/${slug}/records`, data);
|
|
895
957
|
}
|
|
896
958
|
/**
|
|
897
959
|
* Update a record
|
|
960
|
+
* Only provided fields will be updated, existing data is preserved
|
|
898
961
|
*
|
|
899
962
|
* @example
|
|
900
963
|
* ```typescript
|
|
901
|
-
* const updated = await client.entities.updateRecord('
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
* },
|
|
964
|
+
* const updated = await client.entities.updateRecord('customers', 1, {
|
|
965
|
+
* tier: 'vip',
|
|
966
|
+
* email: 'new@abc.com'
|
|
905
967
|
* });
|
|
906
968
|
* ```
|
|
907
969
|
*/
|
|
908
970
|
async updateRecord(slug, id, data) {
|
|
909
|
-
return this.http.put(`/entities/${slug}/${id}`, data);
|
|
971
|
+
return this.http.put(`/entities/${slug}/records/${id}`, data);
|
|
910
972
|
}
|
|
911
973
|
/**
|
|
912
974
|
* Delete a record
|
|
913
975
|
*
|
|
914
976
|
* @example
|
|
915
977
|
* ```typescript
|
|
916
|
-
* await client.entities.deleteRecord('
|
|
978
|
+
* await client.entities.deleteRecord('customers', 1);
|
|
917
979
|
* ```
|
|
918
980
|
*/
|
|
919
981
|
async deleteRecord(slug, id) {
|
|
920
|
-
return this.http.delete(`/entities/${slug}/${id}`);
|
|
982
|
+
return this.http.delete(`/entities/${slug}/records/${id}`);
|
|
921
983
|
}
|
|
922
984
|
// ============================================
|
|
923
985
|
// Helper Methods
|
|
@@ -927,7 +989,7 @@ var EntitiesResource = class {
|
|
|
927
989
|
*
|
|
928
990
|
* @example
|
|
929
991
|
* ```typescript
|
|
930
|
-
* const record = await client.entities.getRecord('
|
|
992
|
+
* const record = await client.entities.getRecord('customers', 1);
|
|
931
993
|
* const company = client.entities.getValue(record, 'company');
|
|
932
994
|
* ```
|
|
933
995
|
*/
|
|
@@ -945,7 +1007,7 @@ var EntitiesResource = class {
|
|
|
945
1007
|
* tier: 'standard' | 'vip';
|
|
946
1008
|
* }
|
|
947
1009
|
*
|
|
948
|
-
* const customers = client.entities.typed<Customer>('
|
|
1010
|
+
* const customers = client.entities.typed<Customer>('customers');
|
|
949
1011
|
* const list = await customers.list(); // Typed records
|
|
950
1012
|
* const record = await customers.get(1);
|
|
951
1013
|
* console.log(record.data.company); // TypeScript knows this is string
|
|
@@ -964,12 +1026,12 @@ var EntitiesResource = class {
|
|
|
964
1026
|
const record = await this.getRecord(slug, id);
|
|
965
1027
|
return record;
|
|
966
1028
|
},
|
|
967
|
-
create: async (data
|
|
968
|
-
const record = await this.createRecord(slug,
|
|
1029
|
+
create: async (data) => {
|
|
1030
|
+
const record = await this.createRecord(slug, data);
|
|
969
1031
|
return record;
|
|
970
1032
|
},
|
|
971
|
-
update: async (id, data
|
|
972
|
-
const record = await this.updateRecord(slug, id,
|
|
1033
|
+
update: async (id, data) => {
|
|
1034
|
+
const record = await this.updateRecord(slug, id, data);
|
|
973
1035
|
return record;
|
|
974
1036
|
},
|
|
975
1037
|
delete: (id) => this.deleteRecord(slug, id)
|
package/dist/index.mjs
CHANGED
|
@@ -184,8 +184,8 @@ var HttpClient = class {
|
|
|
184
184
|
/**
|
|
185
185
|
* DELETE request
|
|
186
186
|
*/
|
|
187
|
-
delete(endpoint) {
|
|
188
|
-
return this.request(endpoint, { method: "DELETE" });
|
|
187
|
+
delete(endpoint, params) {
|
|
188
|
+
return this.request(endpoint, { method: "DELETE", params });
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Upload file
|
|
@@ -776,16 +776,16 @@ var EntitiesResource = class {
|
|
|
776
776
|
this.http = http;
|
|
777
777
|
}
|
|
778
778
|
// ============================================
|
|
779
|
-
//
|
|
779
|
+
// Entity Definitions CRUD
|
|
780
780
|
// ============================================
|
|
781
781
|
/**
|
|
782
|
-
* List all
|
|
783
|
-
* @returns Array of entities
|
|
782
|
+
* List all custom entities
|
|
783
|
+
* @returns Array of entities
|
|
784
784
|
*
|
|
785
785
|
* @example
|
|
786
786
|
* ```typescript
|
|
787
787
|
* const entities = await client.entities.list();
|
|
788
|
-
* // [{ id: 1, name: 'Customer', slug: 'customer', ... }]
|
|
788
|
+
* // [{ id: 1, name: 'Customer', slug: 'customer', records_count: 150, ... }]
|
|
789
789
|
* ```
|
|
790
790
|
*/
|
|
791
791
|
async list() {
|
|
@@ -793,19 +793,84 @@ var EntitiesResource = class {
|
|
|
793
793
|
return response.data;
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
|
-
*
|
|
796
|
+
* Create a new entity definition
|
|
797
797
|
*
|
|
798
798
|
* @example
|
|
799
799
|
* ```typescript
|
|
800
|
-
* const
|
|
801
|
-
*
|
|
800
|
+
* const entity = await client.entities.create({
|
|
801
|
+
* name: '고객',
|
|
802
|
+
* slug: 'customers', // optional, auto-generated from name
|
|
803
|
+
* description: '고객 관리',
|
|
804
|
+
* schema: {
|
|
805
|
+
* fields: [
|
|
806
|
+
* { name: 'company', label: '회사명', type: 'text', required: true },
|
|
807
|
+
* { name: 'email', label: '이메일', type: 'email', required: true },
|
|
808
|
+
* { name: 'status', label: '상태', type: 'select', options: [
|
|
809
|
+
* { value: 'active', label: '활성' },
|
|
810
|
+
* { value: 'inactive', label: '비활성' }
|
|
811
|
+
* ]}
|
|
812
|
+
* ]
|
|
813
|
+
* },
|
|
814
|
+
* icon: 'users'
|
|
815
|
+
* });
|
|
816
|
+
* ```
|
|
817
|
+
*/
|
|
818
|
+
async create(data) {
|
|
819
|
+
return this.http.post("/entities", data);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Get entity definition by slug (includes schema)
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```typescript
|
|
826
|
+
* const entity = await client.entities.get('customers');
|
|
827
|
+
* console.log(entity.schema.fields);
|
|
828
|
+
* ```
|
|
829
|
+
*/
|
|
830
|
+
async get(slug) {
|
|
831
|
+
return this.http.get(`/entities/${slug}`);
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Update an entity definition
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* ```typescript
|
|
838
|
+
* const updated = await client.entities.update('customers', {
|
|
839
|
+
* name: '고객사',
|
|
840
|
+
* description: '고객사 관리'
|
|
841
|
+
* });
|
|
802
842
|
* ```
|
|
803
843
|
*/
|
|
844
|
+
async update(slug, data) {
|
|
845
|
+
return this.http.put(`/entities/${slug}`, data);
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Delete an entity definition
|
|
849
|
+
* If entity has records, use force=true to delete anyway
|
|
850
|
+
*
|
|
851
|
+
* @example
|
|
852
|
+
* ```typescript
|
|
853
|
+
* // Will fail if entity has records
|
|
854
|
+
* await client.entities.delete('customers');
|
|
855
|
+
*
|
|
856
|
+
* // Force delete with all records
|
|
857
|
+
* await client.entities.delete('customers', true);
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
async delete(slug, force = false) {
|
|
861
|
+
const params = force ? { force: "true" } : void 0;
|
|
862
|
+
return this.http.delete(`/entities/${slug}`, params);
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Get entity schema (convenience method)
|
|
866
|
+
* @deprecated Use get(slug) instead - it includes schema
|
|
867
|
+
*/
|
|
804
868
|
async getSchema(slug) {
|
|
805
|
-
|
|
869
|
+
const entity = await this.get(slug);
|
|
870
|
+
return entity.schema;
|
|
806
871
|
}
|
|
807
872
|
// ============================================
|
|
808
|
-
// Records
|
|
873
|
+
// Records CRUD
|
|
809
874
|
// ============================================
|
|
810
875
|
/**
|
|
811
876
|
* List records for an entity
|
|
@@ -814,82 +879,79 @@ var EntitiesResource = class {
|
|
|
814
879
|
* @example
|
|
815
880
|
* ```typescript
|
|
816
881
|
* // Basic listing
|
|
817
|
-
* const customers = await client.entities.listRecords('
|
|
882
|
+
* const customers = await client.entities.listRecords('customers');
|
|
818
883
|
*
|
|
819
|
-
* // With pagination
|
|
820
|
-
* const customers = await client.entities.listRecords('
|
|
884
|
+
* // With pagination and search
|
|
885
|
+
* const customers = await client.entities.listRecords('customers', {
|
|
821
886
|
* page: 1,
|
|
822
887
|
* per_page: 20,
|
|
823
|
-
*
|
|
888
|
+
* search: 'ACME',
|
|
889
|
+
* sort: 'company',
|
|
890
|
+
* dir: 'asc'
|
|
824
891
|
* });
|
|
825
892
|
*
|
|
826
|
-
* // With filtering
|
|
827
|
-
* const vipCustomers = await client.entities.listRecords('
|
|
828
|
-
*
|
|
893
|
+
* // With filtering
|
|
894
|
+
* const vipCustomers = await client.entities.listRecords('customers', {
|
|
895
|
+
* filters: JSON.stringify({ tier: 'vip' })
|
|
829
896
|
* });
|
|
830
897
|
* ```
|
|
831
898
|
*/
|
|
832
899
|
async listRecords(slug, params) {
|
|
833
|
-
return this.http.getList(`/entities/${slug}`, params);
|
|
900
|
+
return this.http.getList(`/entities/${slug}/records`, params);
|
|
834
901
|
}
|
|
835
902
|
/**
|
|
836
903
|
* Get a single record by ID
|
|
837
904
|
*
|
|
838
905
|
* @example
|
|
839
906
|
* ```typescript
|
|
840
|
-
* const customer = await client.entities.getRecord('
|
|
907
|
+
* const customer = await client.entities.getRecord('customers', 1);
|
|
841
908
|
* console.log(customer.data.company); // 'ABC Corp'
|
|
842
909
|
* ```
|
|
843
910
|
*/
|
|
844
911
|
async getRecord(slug, id) {
|
|
845
|
-
return this.http.get(`/entities/${slug}/${id}`);
|
|
912
|
+
return this.http.get(`/entities/${slug}/records/${id}`);
|
|
846
913
|
}
|
|
847
|
-
// ============================================
|
|
848
|
-
// Records (Protected - requires auth)
|
|
849
|
-
// ============================================
|
|
850
914
|
/**
|
|
851
915
|
* Create a new record
|
|
916
|
+
* Request body fields are defined by entity schema
|
|
852
917
|
*
|
|
853
918
|
* @example
|
|
854
919
|
* ```typescript
|
|
855
|
-
* const newCustomer = await client.entities.createRecord('
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
* tier: 'standard',
|
|
860
|
-
* },
|
|
861
|
-
* status: 'active',
|
|
920
|
+
* const newCustomer = await client.entities.createRecord('customers', {
|
|
921
|
+
* company: 'ABC Corp',
|
|
922
|
+
* email: 'contact@abc.com',
|
|
923
|
+
* tier: 'standard',
|
|
862
924
|
* });
|
|
863
925
|
* ```
|
|
864
926
|
*/
|
|
865
927
|
async createRecord(slug, data) {
|
|
866
|
-
return this.http.post(`/entities/${slug}`, data);
|
|
928
|
+
return this.http.post(`/entities/${slug}/records`, data);
|
|
867
929
|
}
|
|
868
930
|
/**
|
|
869
931
|
* Update a record
|
|
932
|
+
* Only provided fields will be updated, existing data is preserved
|
|
870
933
|
*
|
|
871
934
|
* @example
|
|
872
935
|
* ```typescript
|
|
873
|
-
* const updated = await client.entities.updateRecord('
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* },
|
|
936
|
+
* const updated = await client.entities.updateRecord('customers', 1, {
|
|
937
|
+
* tier: 'vip',
|
|
938
|
+
* email: 'new@abc.com'
|
|
877
939
|
* });
|
|
878
940
|
* ```
|
|
879
941
|
*/
|
|
880
942
|
async updateRecord(slug, id, data) {
|
|
881
|
-
return this.http.put(`/entities/${slug}/${id}`, data);
|
|
943
|
+
return this.http.put(`/entities/${slug}/records/${id}`, data);
|
|
882
944
|
}
|
|
883
945
|
/**
|
|
884
946
|
* Delete a record
|
|
885
947
|
*
|
|
886
948
|
* @example
|
|
887
949
|
* ```typescript
|
|
888
|
-
* await client.entities.deleteRecord('
|
|
950
|
+
* await client.entities.deleteRecord('customers', 1);
|
|
889
951
|
* ```
|
|
890
952
|
*/
|
|
891
953
|
async deleteRecord(slug, id) {
|
|
892
|
-
return this.http.delete(`/entities/${slug}/${id}`);
|
|
954
|
+
return this.http.delete(`/entities/${slug}/records/${id}`);
|
|
893
955
|
}
|
|
894
956
|
// ============================================
|
|
895
957
|
// Helper Methods
|
|
@@ -899,7 +961,7 @@ var EntitiesResource = class {
|
|
|
899
961
|
*
|
|
900
962
|
* @example
|
|
901
963
|
* ```typescript
|
|
902
|
-
* const record = await client.entities.getRecord('
|
|
964
|
+
* const record = await client.entities.getRecord('customers', 1);
|
|
903
965
|
* const company = client.entities.getValue(record, 'company');
|
|
904
966
|
* ```
|
|
905
967
|
*/
|
|
@@ -917,7 +979,7 @@ var EntitiesResource = class {
|
|
|
917
979
|
* tier: 'standard' | 'vip';
|
|
918
980
|
* }
|
|
919
981
|
*
|
|
920
|
-
* const customers = client.entities.typed<Customer>('
|
|
982
|
+
* const customers = client.entities.typed<Customer>('customers');
|
|
921
983
|
* const list = await customers.list(); // Typed records
|
|
922
984
|
* const record = await customers.get(1);
|
|
923
985
|
* console.log(record.data.company); // TypeScript knows this is string
|
|
@@ -936,12 +998,12 @@ var EntitiesResource = class {
|
|
|
936
998
|
const record = await this.getRecord(slug, id);
|
|
937
999
|
return record;
|
|
938
1000
|
},
|
|
939
|
-
create: async (data
|
|
940
|
-
const record = await this.createRecord(slug,
|
|
1001
|
+
create: async (data) => {
|
|
1002
|
+
const record = await this.createRecord(slug, data);
|
|
941
1003
|
return record;
|
|
942
1004
|
},
|
|
943
|
-
update: async (id, data
|
|
944
|
-
const record = await this.updateRecord(slug, id,
|
|
1005
|
+
update: async (id, data) => {
|
|
1006
|
+
const record = await this.updateRecord(slug, id, data);
|
|
945
1007
|
return record;
|
|
946
1008
|
},
|
|
947
1009
|
delete: (id) => this.deleteRecord(slug, id)
|