@back23/promptly-sdk 2.1.0 → 2.2.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 CHANGED
File without changes
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 active custom entities
1163
- * @returns Array of entities (always an array)
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
- * Get entity schema by slug
1192
+ * Create a new entity definition
1174
1193
  *
1175
1194
  * @example
1176
1195
  * ```typescript
1177
- * const schema = await client.entities.getSchema('customer');
1178
- * // { fields: [{ name: 'company', label: '회사명', type: 'text', ... }] }
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('customer');
1263
+ * const customers = await client.entities.listRecords('customers');
1190
1264
  *
1191
- * // With pagination
1192
- * const customers = await client.entities.listRecords('customer', {
1265
+ * // With pagination and search
1266
+ * const customers = await client.entities.listRecords('customers', {
1193
1267
  * page: 1,
1194
1268
  * per_page: 20,
1195
- * status: 'active',
1269
+ * search: 'ACME',
1270
+ * sort: 'company',
1271
+ * dir: 'asc'
1196
1272
  * });
1197
1273
  *
1198
- * // With filtering by data fields
1199
- * const vipCustomers = await client.entities.listRecords('customer', {
1200
- * 'data.tier': 'vip',
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('customer', 1);
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('customer', {
1221
- * data: {
1222
- * company: 'ABC Corp',
1223
- * email: 'contact@abc.com',
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: CreateEntityRecordData): Promise<EntityRecord>;
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('customer', 1, {
1237
- * data: {
1238
- * tier: 'vip',
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: UpdateEntityRecordData): Promise<EntityRecord>;
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('customer', 1);
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('customer', 1);
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>('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, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
1364
+ create: (data: T) => Promise<Omit<EntityRecord, "data"> & {
1291
1365
  data: T;
1292
1366
  }>;
1293
- update: (id: number, data: Partial<T>, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
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 active custom entities
1163
- * @returns Array of entities (always an array)
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
- * Get entity schema by slug
1192
+ * Create a new entity definition
1174
1193
  *
1175
1194
  * @example
1176
1195
  * ```typescript
1177
- * const schema = await client.entities.getSchema('customer');
1178
- * // { fields: [{ name: 'company', label: '회사명', type: 'text', ... }] }
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('customer');
1263
+ * const customers = await client.entities.listRecords('customers');
1190
1264
  *
1191
- * // With pagination
1192
- * const customers = await client.entities.listRecords('customer', {
1265
+ * // With pagination and search
1266
+ * const customers = await client.entities.listRecords('customers', {
1193
1267
  * page: 1,
1194
1268
  * per_page: 20,
1195
- * status: 'active',
1269
+ * search: 'ACME',
1270
+ * sort: 'company',
1271
+ * dir: 'asc'
1196
1272
  * });
1197
1273
  *
1198
- * // With filtering by data fields
1199
- * const vipCustomers = await client.entities.listRecords('customer', {
1200
- * 'data.tier': 'vip',
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('customer', 1);
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('customer', {
1221
- * data: {
1222
- * company: 'ABC Corp',
1223
- * email: 'contact@abc.com',
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: CreateEntityRecordData): Promise<EntityRecord>;
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('customer', 1, {
1237
- * data: {
1238
- * tier: 'vip',
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: UpdateEntityRecordData): Promise<EntityRecord>;
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('customer', 1);
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('customer', 1);
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>('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, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
1364
+ create: (data: T) => Promise<Omit<EntityRecord, "data"> & {
1291
1365
  data: T;
1292
1366
  }>;
1293
- update: (id: number, data: Partial<T>, status?: EntityRecord["status"]) => Promise<Omit<EntityRecord, "data"> & {
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
- // Entities (Public)
807
+ // Entity Definitions CRUD
808
808
  // ============================================
809
809
  /**
810
- * List all active custom entities
811
- * @returns Array of entities (always an array)
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
- * Get entity schema by slug
824
+ * Create a new entity definition
825
825
  *
826
826
  * @example
827
827
  * ```typescript
828
- * const schema = await client.entities.getSchema('customer');
829
- * // { fields: [{ name: 'company', label: '회사명', type: 'text', ... }] }
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
- return this.http.get(`/entities/${slug}/schema`);
897
+ const entity = await this.get(slug);
898
+ return entity.schema;
834
899
  }
835
900
  // ============================================
836
- // Records (Public Read)
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('customer');
910
+ * const customers = await client.entities.listRecords('customers');
846
911
  *
847
- * // With pagination
848
- * const customers = await client.entities.listRecords('customer', {
912
+ * // With pagination and search
913
+ * const customers = await client.entities.listRecords('customers', {
849
914
  * page: 1,
850
915
  * per_page: 20,
851
- * status: 'active',
916
+ * search: 'ACME',
917
+ * sort: 'company',
918
+ * dir: 'asc'
852
919
  * });
853
920
  *
854
- * // With filtering by data fields
855
- * const vipCustomers = await client.entities.listRecords('customer', {
856
- * 'data.tier': 'vip',
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('customer', 1);
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('customer', {
884
- * data: {
885
- * company: 'ABC Corp',
886
- * email: 'contact@abc.com',
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('customer', 1, {
902
- * data: {
903
- * tier: 'vip',
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('customer', 1);
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('customer', 1);
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>('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, status) => {
968
- const record = await this.createRecord(slug, { data, status });
1029
+ create: async (data) => {
1030
+ const record = await this.createRecord(slug, data);
969
1031
  return record;
970
1032
  },
971
- update: async (id, data, status) => {
972
- const record = await this.updateRecord(slug, id, { data, status });
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
- // Entities (Public)
779
+ // Entity Definitions CRUD
780
780
  // ============================================
781
781
  /**
782
- * List all active custom entities
783
- * @returns Array of entities (always an array)
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
- * Get entity schema by slug
796
+ * Create a new entity definition
797
797
  *
798
798
  * @example
799
799
  * ```typescript
800
- * const schema = await client.entities.getSchema('customer');
801
- * // { fields: [{ name: 'company', label: '회사명', type: 'text', ... }] }
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
- return this.http.get(`/entities/${slug}/schema`);
869
+ const entity = await this.get(slug);
870
+ return entity.schema;
806
871
  }
807
872
  // ============================================
808
- // Records (Public Read)
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('customer');
882
+ * const customers = await client.entities.listRecords('customers');
818
883
  *
819
- * // With pagination
820
- * const customers = await client.entities.listRecords('customer', {
884
+ * // With pagination and search
885
+ * const customers = await client.entities.listRecords('customers', {
821
886
  * page: 1,
822
887
  * per_page: 20,
823
- * status: 'active',
888
+ * search: 'ACME',
889
+ * sort: 'company',
890
+ * dir: 'asc'
824
891
  * });
825
892
  *
826
- * // With filtering by data fields
827
- * const vipCustomers = await client.entities.listRecords('customer', {
828
- * 'data.tier': 'vip',
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('customer', 1);
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('customer', {
856
- * data: {
857
- * company: 'ABC Corp',
858
- * email: 'contact@abc.com',
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('customer', 1, {
874
- * data: {
875
- * tier: 'vip',
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('customer', 1);
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('customer', 1);
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>('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, status) => {
940
- const record = await this.createRecord(slug, { data, status });
1001
+ create: async (data) => {
1002
+ const record = await this.createRecord(slug, data);
941
1003
  return record;
942
1004
  },
943
- update: async (id, data, status) => {
944
- const record = await this.updateRecord(slug, id, { data, status });
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@back23/promptly-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Promptly AI CMS SDK for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",