@back23/promptly-sdk 2.2.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.
Files changed (2) hide show
  1. package/README.md +103 -30
  2. 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, getSchema, listRecords, getRecord | createRecord, updateRecord, deleteRecord |
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 (커스텀 엔티티) - AI가 생성한 동적 데이터
529
+ ### Entities (커스텀 엔티티) - 동적 데이터 구조
481
530
 
482
- AI가 MCP를 통해 생성한 커스텀 데이터 구조에 접근합니다.
531
+ API/SDK에서 직접 엔티티 정의를 생성하고 데이터를 관리할 수 있습니다.
483
532
 
484
- #### Public
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 schema = await client.entities.getSchema('customer');
493
- // Returns: EntitySchema
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('customer', {
577
+ const { data: customers, meta } = await client.entities.listRecords('customers', {
497
578
  page: 1,
498
579
  per_page: 20,
499
- status: 'active',
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('customer', 1);
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
- #### Protected (로그인 필요)
515
-
516
- ```typescript
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('customer', 1, {
529
- data: { tier: 'vip' },
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('customer', 1);
606
+ await client.entities.deleteRecord('customers', 1);
534
607
  ```
535
608
 
536
609
  #### TypeScript 타입 지원
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@back23/promptly-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Promptly AI CMS SDK for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",