@back23/promptly-sdk 2.0.1 → 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/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
@@ -379,29 +379,29 @@ var BoardsResource = class {
379
379
  * @returns ListResponse with data array (always defined) and pagination meta
380
380
  */
381
381
  async list(params) {
382
- return this.http.getList("/public/boards", params);
382
+ return this.http.getList("/boards", params);
383
383
  }
384
384
  /**
385
385
  * Get board by ID or slug
386
386
  */
387
387
  async get(idOrSlug) {
388
- return this.http.get(`/public/boards/${idOrSlug}`);
388
+ return this.http.get(`/boards/${idOrSlug}`);
389
389
  }
390
390
  // ============================================
391
- // Posts (Public)
391
+ // Posts
392
392
  // ============================================
393
393
  /**
394
394
  * List posts in a board
395
395
  * @returns ListResponse with data array and pagination meta
396
396
  */
397
397
  async listPosts(boardIdOrSlug, params) {
398
- return this.http.getList(`/public/boards/${boardIdOrSlug}/posts`, params);
398
+ return this.http.getList(`/boards/${boardIdOrSlug}/posts`, params);
399
399
  }
400
400
  /**
401
401
  * Get post by ID
402
402
  */
403
403
  async getPost(postId) {
404
- return this.http.get(`/public/posts/${postId}`);
404
+ return this.http.get(`/posts/${postId}`);
405
405
  }
406
406
  // ============================================
407
407
  // Posts (Protected - requires auth)
@@ -432,7 +432,7 @@ var BoardsResource = class {
432
432
  * @returns Array of comments (always an array, never null/undefined)
433
433
  */
434
434
  async listComments(postId) {
435
- const response = await this.http.getList(`/public/posts/${postId}/comments`);
435
+ const response = await this.http.getList(`/posts/${postId}/comments`);
436
436
  return response.data;
437
437
  }
438
438
  /**
@@ -465,26 +465,26 @@ var BlogResource = class {
465
465
  * @returns ListResponse with data array (always defined) and pagination meta
466
466
  */
467
467
  async list(params) {
468
- return this.http.getList("/public/blog", params);
468
+ return this.http.getList("/blog", params);
469
469
  }
470
470
  /**
471
471
  * Get blog post by slug
472
472
  */
473
473
  async get(slug) {
474
- return this.http.get(`/public/blog/${slug}`);
474
+ return this.http.get(`/blog/${slug}`);
475
475
  }
476
476
  /**
477
477
  * Get blog post by ID
478
478
  */
479
479
  async getById(id) {
480
- return this.http.get(`/public/blog/id/${id}`);
480
+ return this.http.get(`/blog/id/${id}`);
481
481
  }
482
482
  /**
483
483
  * Get featured blog posts
484
484
  * @returns Array of featured posts (always an array, never null/undefined)
485
485
  */
486
486
  async featured(limit = 5) {
487
- const response = await this.http.getList("/public/blog", {
487
+ const response = await this.http.getList("/blog", {
488
488
  per_page: limit,
489
489
  featured: true
490
490
  });
@@ -495,7 +495,7 @@ var BlogResource = class {
495
495
  * @returns ListResponse with data array and pagination meta
496
496
  */
497
497
  async byCategory(category, params) {
498
- return this.http.getList("/public/blog", {
498
+ return this.http.getList("/blog", {
499
499
  ...params,
500
500
  category
501
501
  });
@@ -505,7 +505,7 @@ var BlogResource = class {
505
505
  * @returns ListResponse with data array and pagination meta
506
506
  */
507
507
  async byTag(tag, params) {
508
- return this.http.getList("/public/blog", {
508
+ return this.http.getList("/blog", {
509
509
  ...params,
510
510
  tag
511
511
  });
@@ -515,7 +515,7 @@ var BlogResource = class {
515
515
  * @returns ListResponse with data array and pagination meta
516
516
  */
517
517
  async search(query, params) {
518
- return this.http.getList("/public/blog", {
518
+ return this.http.getList("/blog", {
519
519
  ...params,
520
520
  search: query
521
521
  });
@@ -525,7 +525,7 @@ var BlogResource = class {
525
525
  * @returns Array of category names (always an array)
526
526
  */
527
527
  async categories() {
528
- const response = await this.http.get("/public/blog/categories");
528
+ const response = await this.http.get("/blog/categories");
529
529
  return Array.isArray(response) ? response : response?.data ?? [];
530
530
  }
531
531
  /**
@@ -533,7 +533,7 @@ var BlogResource = class {
533
533
  * @returns Array of tag names (always an array)
534
534
  */
535
535
  async tags() {
536
- const response = await this.http.get("/public/blog/tags");
536
+ const response = await this.http.get("/blog/tags");
537
537
  return Array.isArray(response) ? response : response?.data ?? [];
538
538
  }
539
539
  };
@@ -548,19 +548,19 @@ var FormsResource = class {
548
548
  * @returns ListResponse with data array and pagination meta
549
549
  */
550
550
  async list(params) {
551
- return this.http.getList("/public/forms", params);
551
+ return this.http.getList("/forms", params);
552
552
  }
553
553
  /**
554
554
  * Get form by ID or slug
555
555
  */
556
556
  async get(idOrSlug) {
557
- return this.http.get(`/public/forms/${idOrSlug}`);
557
+ return this.http.get(`/forms/${idOrSlug}`);
558
558
  }
559
559
  /**
560
560
  * Submit form data
561
561
  */
562
562
  async submit(formIdOrSlug, data) {
563
- return this.http.post(`/public/forms/${formIdOrSlug}/submit`, data);
563
+ return this.http.post(`/forms/${formIdOrSlug}/submit`, data);
564
564
  }
565
565
  // ============================================
566
566
  // Protected endpoints (requires auth)
@@ -593,20 +593,20 @@ var ShopResource = class {
593
593
  * @returns ListResponse with data array and pagination meta
594
594
  */
595
595
  async listProducts(params) {
596
- return this.http.getList("/public/products", params);
596
+ return this.http.getList("/products", params);
597
597
  }
598
598
  /**
599
599
  * Get product by ID or slug
600
600
  */
601
601
  async getProduct(idOrSlug) {
602
- return this.http.get(`/public/products/${idOrSlug}`);
602
+ return this.http.get(`/products/${idOrSlug}`);
603
603
  }
604
604
  /**
605
605
  * Get featured products
606
606
  * @returns Array of featured products (always an array)
607
607
  */
608
608
  async featuredProducts(limit = 8) {
609
- const response = await this.http.getList("/public/products", {
609
+ const response = await this.http.getList("/products", {
610
610
  per_page: limit,
611
611
  is_featured: true
612
612
  });
@@ -617,7 +617,7 @@ var ShopResource = class {
617
617
  * @returns ListResponse with data array and pagination meta
618
618
  */
619
619
  async searchProducts(query, params) {
620
- return this.http.getList("/public/products", {
620
+ return this.http.getList("/products", {
621
621
  ...params,
622
622
  search: query
623
623
  });
@@ -630,21 +630,21 @@ var ShopResource = class {
630
630
  * @returns Array of categories (always an array)
631
631
  */
632
632
  async listCategories() {
633
- const response = await this.http.getList("/public/categories");
633
+ const response = await this.http.getList("/categories");
634
634
  return response.data;
635
635
  }
636
636
  /**
637
637
  * Get category by ID or slug
638
638
  */
639
639
  async getCategory(idOrSlug) {
640
- return this.http.get(`/public/categories/${idOrSlug}`);
640
+ return this.http.get(`/categories/${idOrSlug}`);
641
641
  }
642
642
  /**
643
643
  * Get products in category
644
644
  * @returns ListResponse with data array and pagination meta
645
645
  */
646
646
  async categoryProducts(categoryIdOrSlug, params) {
647
- return this.http.getList(`/public/categories/${categoryIdOrSlug}/products`, params);
647
+ return this.http.getList(`/categories/${categoryIdOrSlug}/products`, params);
648
648
  }
649
649
  // ============================================
650
650
  // Cart
@@ -804,36 +804,101 @@ 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() {
820
- const response = await this.http.getList("/public/entities");
820
+ const response = await this.http.getList("/entities");
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(`/public/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(`/public/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(`/public/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)
@@ -990,14 +1052,14 @@ var ReservationResource = class {
990
1052
  * @returns Reservation settings for the tenant
991
1053
  */
992
1054
  async getSettings() {
993
- return this.http.get("/public/reservation/settings");
1055
+ return this.http.get("/reservation/settings");
994
1056
  }
995
1057
  /**
996
1058
  * List available services
997
1059
  * @returns Array of services (always an array)
998
1060
  */
999
1061
  async listServices() {
1000
- const response = await this.http.getList("/public/reservation/services");
1062
+ const response = await this.http.getList("/reservation/services");
1001
1063
  return response.data;
1002
1064
  }
1003
1065
  /**
@@ -1007,7 +1069,7 @@ var ReservationResource = class {
1007
1069
  */
1008
1070
  async listStaff(serviceId) {
1009
1071
  const params = serviceId ? { service_id: serviceId } : void 0;
1010
- const response = await this.http.getList("/public/reservation/staffs", params);
1072
+ const response = await this.http.getList("/reservation/staffs", params);
1011
1073
  return response.data;
1012
1074
  }
1013
1075
  /**
@@ -1015,7 +1077,7 @@ var ReservationResource = class {
1015
1077
  * @returns Array of available date strings (YYYY-MM-DD)
1016
1078
  */
1017
1079
  async getAvailableDates(params) {
1018
- const response = await this.http.get("/public/reservation/available-dates", params);
1080
+ const response = await this.http.get("/reservation/available-dates", params);
1019
1081
  return Array.isArray(response) ? response : response?.data ?? [];
1020
1082
  }
1021
1083
  /**
@@ -1023,7 +1085,7 @@ var ReservationResource = class {
1023
1085
  * @returns Array of available slots (always an array)
1024
1086
  */
1025
1087
  async getAvailableSlots(params) {
1026
- const response = await this.http.get("/public/reservation/available-slots", params);
1088
+ const response = await this.http.get("/reservation/available-slots", params);
1027
1089
  return Array.isArray(response) ? response : response?.data ?? [];
1028
1090
  }
1029
1091
  // ============================================