@ptkl/sdk 0.9.12 → 0.10.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.esm.js CHANGED
@@ -114,27 +114,6 @@ class Functions extends PlatformBaseClient {
114
114
  }
115
115
  }
116
116
 
117
- class Roles extends PlatformBaseClient {
118
- async create(role) {
119
- return await this.client.post("/v1/user/role/create", role);
120
- }
121
- async delete(uuid) {
122
- return await this.client.delete(`/v1/user/role/delete/${uuid}`);
123
- }
124
- async list() {
125
- return await this.client.get(`/v1/user/role/list`);
126
- }
127
- async availablePermissions() {
128
- return await this.client.get(`/v1/user/permissions/list`);
129
- }
130
- async permissions() {
131
- return await this.client.get(`/v1/user/role/permissions`);
132
- }
133
- async edit(permissions, workspaces, level, uuid) {
134
- return await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
135
- }
136
- }
137
-
138
117
  class APIUser extends PlatformBaseClient {
139
118
  async auth(username, password, project) {
140
119
  return this.client.post("/v1/user/api/auth", {
@@ -164,36 +143,110 @@ class APIUser extends PlatformBaseClient {
164
143
  }
165
144
 
166
145
  class Users extends PlatformBaseClient {
167
- async invite(email, roles) {
168
- return await this.client.post("/v1/project/invite", {
146
+ async auth(username, password, project) {
147
+ return await this.client.post("/v1/user/login", {
148
+ username,
149
+ password,
150
+ response_type: 'token',
151
+ }, {
152
+ headers: {
153
+ 'X-Project-Uuid': project
154
+ }
155
+ });
156
+ }
157
+ /**
158
+ * Resend confirmation email
159
+ * @param email User email
160
+ */
161
+ async resendConfirmationEmail(email) {
162
+ return await this.client.post("/v1/user/send/confirmation/email", {
169
163
  email,
170
- roles,
171
164
  });
172
165
  }
173
- //Gets the current user's claims
174
- async getClaims() {
175
- return await this.client.get("/v1/user/claims");
166
+ // Password Reset (Request Only)
167
+ // Note: Only the REQUEST is exposed, not the password reset completion
168
+ // The actual password reset should be done through the official web interface
169
+ /**
170
+ * Request password reset email
171
+ * This only sends an email with a reset link, does not expose or change passwords
172
+ * @param email User email
173
+ */
174
+ async requestPasswordReset(email) {
175
+ return await this.client.post("/v1/user/resetpassword", { email });
176
176
  }
177
- //Gets the current user's model
177
+ // User Profile & Management
178
+ /**
179
+ * Get current user's model
180
+ */
178
181
  async getUser() {
179
182
  return await this.client.get("/v1/user/model");
180
183
  }
181
- async delete(uuid) {
182
- return await this.client.delete(`/v1/project/user/${uuid}`);
184
+ /**
185
+ * Get current user's claims
186
+ */
187
+ async getClaims() {
188
+ return await this.client.get("/v1/user/claims");
183
189
  }
184
- async permissions() {
185
- return await this.client.delete(`/v1/user/role/permissions`);
190
+ /**
191
+ * Edit user profile
192
+ * @param data Profile update data
193
+ */
194
+ async editProfile(data) {
195
+ return await this.client.post("/v1/user/profile/edit", data);
186
196
  }
187
- async auth(username, password, project) {
188
- return await this.client.post("/v1/user/login", {
189
- username,
190
- password,
191
- response_type: "token",
192
- }, {
193
- headers: {
194
- "X-Project-Uuid": project,
195
- }
196
- });
197
+ // Permissions & Roles
198
+ /**
199
+ * Get user permissions
200
+ */
201
+ async getPermissions() {
202
+ return await this.client.get("/v1/user/role/permissions");
203
+ }
204
+ /**
205
+ * Get list of available permissions
206
+ */
207
+ async listPermissions() {
208
+ return await this.client.get("/v1/user/permissions/list");
209
+ }
210
+ /**
211
+ * Create a new role
212
+ * @param role Role data including name, permissions, workspaces, and level
213
+ */
214
+ async createRole(role) {
215
+ return await this.client.post("/v1/user/role/create", role);
216
+ }
217
+ /**
218
+ * Delete a role
219
+ * @param uuid Role UUID
220
+ */
221
+ async deleteRole(uuid) {
222
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
223
+ }
224
+ /**
225
+ * List all roles
226
+ */
227
+ async listRoles() {
228
+ return await this.client.get(`/v1/user/role/list`);
229
+ }
230
+ /**
231
+ * Get role details by UUID
232
+ * @param uuid Role UUID
233
+ */
234
+ async getRoleModel(uuid) {
235
+ return await this.client.get(`/v1/user/role/edit/${uuid}`);
236
+ }
237
+ /**
238
+ * Edit a role
239
+ * @param uuid Role UUID
240
+ * @param data Role update data including permissions, workspaces, and level
241
+ */
242
+ async editRole(uuid, data) {
243
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
244
+ }
245
+ /**
246
+ * @deprecated Use getPermissions() instead
247
+ */
248
+ async permissions() {
249
+ return await this.client.get(`/v1/user/role/permissions`);
197
250
  }
198
251
  }
199
252
 
@@ -420,6 +473,9 @@ class Component extends PlatformBaseClient {
420
473
  data: input
421
474
  });
422
475
  }
476
+ async revisions(uuid) {
477
+ return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}/revisions`);
478
+ }
423
479
  }
424
480
 
425
481
  class ComponentUtils extends PlatformBaseClient {
@@ -503,6 +559,7 @@ class System extends PlatformBaseClient {
503
559
  async resourceResolver(ref, resourceName, format) {
504
560
  return await this.client.post("/v3/system/resource-resolver", {
505
561
  type: resourceName,
562
+ ref,
506
563
  format,
507
564
  });
508
565
  }
@@ -537,6 +594,199 @@ class Forge extends PlatformBaseClient {
537
594
  }
538
595
  }
539
596
 
597
+ class Project extends PlatformBaseClient {
598
+ /**
599
+ * Get list of all projects for the current user
600
+ */
601
+ async list() {
602
+ return await this.client.get("/v1/project/list");
603
+ }
604
+ /**
605
+ * Create a new project
606
+ * @param data Project creation data
607
+ */
608
+ async create(data) {
609
+ return await this.client.post("/v1/project/create", data);
610
+ }
611
+ /**
612
+ * Get information about a specific project
613
+ */
614
+ async info() {
615
+ return await this.client.get("/v1/project/info");
616
+ }
617
+ /**
618
+ * Archive a project
619
+ */
620
+ async archive() {
621
+ return await this.client.patch("/v1/project/archive");
622
+ }
623
+ /**
624
+ * Invite a user to the project
625
+ * @param email Array of emails
626
+ * @param roles Array of role UUIDs
627
+ */
628
+ async invite(emails, roles) {
629
+ return await this.client.post("/v1/project/invite", { emails: emails.join(","), roles });
630
+ }
631
+ /**
632
+ * Get list of project invites
633
+ */
634
+ async getInvites() {
635
+ return await this.client.get("/v1/project/invites");
636
+ }
637
+ /**
638
+ * Get a specific invite by UUID
639
+ * @param uuid Invite UUID
640
+ */
641
+ async getInvite(uuid) {
642
+ return await this.client.get(`/v1/project/invite/${uuid}`);
643
+ }
644
+ /**
645
+ * Accept an invite
646
+ * @param uuid Invite UUID
647
+ */
648
+ async acceptInvite(uuid) {
649
+ return await this.client.get(`/v1/project/invite/accept/${uuid}`);
650
+ }
651
+ /**
652
+ * Register through an invite
653
+ * @param uuid Invite UUID
654
+ * @param data Registration data
655
+ */
656
+ async registerWithInvite(uuid, data) {
657
+ return await this.client.post(`/v1/project/invite/register/${uuid}`, data);
658
+ }
659
+ /**
660
+ * Get list of project users
661
+ */
662
+ async getUsers() {
663
+ return await this.client.get("/v1/project/users");
664
+ }
665
+ /**
666
+ * Get a specific project user
667
+ * @param uuid User UUID
668
+ */
669
+ async getUser(uuid) {
670
+ return await this.client.get(`/v1/project/user/${uuid}`);
671
+ }
672
+ /**
673
+ * Update a project user
674
+ * @param uuid User UUID
675
+ * @param data Update data
676
+ */
677
+ async updateUser(uuid, data) {
678
+ return await this.client.put(`/v1/project/user/${uuid}`, data);
679
+ }
680
+ /**
681
+ * Delete a user from the project
682
+ * @param uuid User UUID
683
+ */
684
+ async deleteUser(uuid) {
685
+ return await this.client.delete(`/v1/project/user/${uuid}`);
686
+ }
687
+ /**
688
+ * Update project settings
689
+ * @param settings Settings data
690
+ */
691
+ async updateSettings(settings) {
692
+ return await this.client.post("/v1/project/settings", settings);
693
+ }
694
+ // Workspace Methods
695
+ /**
696
+ * Create a new workspace
697
+ * @param data Workspace data
698
+ */
699
+ async createWorkspace(data) {
700
+ return await this.client.post("/v1/project/workspace", data);
701
+ }
702
+ /**
703
+ * Update a workspace
704
+ * @param uuid Workspace UUID
705
+ * @param data Update data
706
+ */
707
+ async updateWorkspace(uuid, data) {
708
+ return await this.client.put(`/v1/project/workspace/${uuid}`, data);
709
+ }
710
+ /**
711
+ * Delete a workspace
712
+ * @param uuid Workspace UUID
713
+ */
714
+ async deleteWorkspace(uuid) {
715
+ return await this.client.delete(`/v1/project/workspace/${uuid}`);
716
+ }
717
+ // Template Methods
718
+ /**
719
+ * Get available templates
720
+ */
721
+ async getAvailableTemplates() {
722
+ return await this.client.get("/v1/project/template/available");
723
+ }
724
+ /**
725
+ * Search for templates
726
+ * @param query Search query
727
+ */
728
+ async searchTemplates(query) {
729
+ return await this.client.post("/v1/project/template/search", query);
730
+ }
731
+ /**
732
+ * Get template by ID
733
+ * @param id Template ID
734
+ */
735
+ async getTemplate(id) {
736
+ return await this.client.get(`/v1/project/template/${id}`);
737
+ }
738
+ /**
739
+ * Get template by activation code
740
+ * @param code Activation code
741
+ */
742
+ async getTemplateByCode(code) {
743
+ return await this.client.get(`/v1/project/template/activationCode/${code}`);
744
+ }
745
+ /**
746
+ * Get templates for a workspace
747
+ */
748
+ async getWorkspaceTemplates() {
749
+ return await this.client.get("/v1/project/template/workspace");
750
+ }
751
+ /**
752
+ * Install a template
753
+ * @param data Installation data
754
+ */
755
+ async installTemplate(data) {
756
+ return await this.client.post("/v1/project/template/install", data);
757
+ }
758
+ /**
759
+ * Uninstall a template
760
+ * @param data Uninstallation data
761
+ */
762
+ async uninstallTemplate(data) {
763
+ return await this.client.post("/v1/project/template/uninstall", data);
764
+ }
765
+ /**
766
+ * Upgrade a template
767
+ * @param data Upgrade data
768
+ */
769
+ async upgradeTemplate(data) {
770
+ return await this.client.post("/v1/project/template/upgrade", data);
771
+ }
772
+ }
773
+
774
+ class Config extends PlatformBaseClient {
775
+ /**
776
+ * Get user configuration
777
+ */
778
+ async getUserConfig() {
779
+ return await this.client.get("/v1/config/user");
780
+ }
781
+ /**
782
+ * Update user configuration
783
+ * @param config Configuration data
784
+ */
785
+ async updateUserConfig(config) {
786
+ return await this.client.put("/v1/config/user", config);
787
+ }
788
+ }
789
+
540
790
  // apis
541
791
  class Platform extends PlatformBaseClient {
542
792
  getPlatformClient() {
@@ -552,9 +802,6 @@ class Platform extends PlatformBaseClient {
552
802
  function() {
553
803
  return (new Functions()).setClient(this.client);
554
804
  }
555
- role() {
556
- return (new Roles()).setClient(this.client);
557
- }
558
805
  user() {
559
806
  return (new Users()).setClient(this.client);
560
807
  }
@@ -585,6 +832,12 @@ class Platform extends PlatformBaseClient {
585
832
  thunder() {
586
833
  return (new Thunder()).setClient(this.client);
587
834
  }
835
+ project() {
836
+ return (new Project()).setClient(this.client);
837
+ }
838
+ config() {
839
+ return (new Config()).setClient(this.client);
840
+ }
588
841
  }
589
842
 
590
843
  class Invoicing extends PlatformBaseClient {
@@ -756,7 +1009,6 @@ class DMS extends IntegrationsBaseClient {
756
1009
  });
757
1010
  if (count == files.length) {
758
1011
  formData.append('path', payload.uploadDir);
759
- formData.append('ref', payload.uuid);
760
1012
  if (payload.public) {
761
1013
  formData.append('is_public', "true");
762
1014
  }
@@ -784,7 +1036,7 @@ class DMS extends IntegrationsBaseClient {
784
1036
  });
785
1037
  }
786
1038
  async getMedia(lib, key, encoding) {
787
- return this.request('GET', `media/library/${lib}/get/${key}`, {
1039
+ return this.request('GET', `media/get/${key}`, {
788
1040
  params: {
789
1041
  encoding
790
1042
  },
@@ -792,21 +1044,21 @@ class DMS extends IntegrationsBaseClient {
792
1044
  });
793
1045
  }
794
1046
  async download(lib, key) {
795
- return this.request('POST', `media/library/${lib}/download`, {
1047
+ return this.request('POST', `media/download`, {
796
1048
  data: {
797
1049
  key
798
1050
  },
799
1051
  responseType: 'blob'
800
1052
  });
801
1053
  }
802
- async getExifData(lib, key) {
803
- return this.request('GET', `media/library/${lib}/exif/${key}`);
1054
+ async getExifData(key) {
1055
+ return this.request('GET', `media/exif/${key}`);
804
1056
  }
805
- async html2pdf(lib, data) {
1057
+ async html2pdf(data) {
806
1058
  const { output_pdf = false, input_path, input_html, output_path, output_file_name, output_type, data: templateData } = data;
807
1059
  const type = output_pdf ? 'arraybuffer' : 'json';
808
1060
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
809
- return this.request('POST', `media/library/${lib}/html2pdf`, {
1061
+ return this.request('POST', `media/pdf/html2pdf`, {
810
1062
  data: {
811
1063
  output_pdf,
812
1064
  input_path,
@@ -822,20 +1074,20 @@ class DMS extends IntegrationsBaseClient {
822
1074
  responseType: type
823
1075
  });
824
1076
  }
825
- async createDir(lib, path) {
826
- return this.request('POST', `media/library/${lib}/dir`, { data: { path } });
1077
+ async createDir(path) {
1078
+ return this.request('POST', `media/library/dir`, { data: { path } });
827
1079
  }
828
- async deleteDir(lib, path) {
829
- return this.request('POST', `media/library/${lib}/delete/dir`, { data: { path } });
1080
+ async deleteDir(path) {
1081
+ return this.request('DELETE', `media/library/dir`, { data: { path } });
830
1082
  }
831
- async dirs(lib, data) {
832
- return await this.request("POST", `media/library/${lib}/dirs`, { data });
1083
+ async dirs(data) {
1084
+ return await this.request("POST", `media/library/dirs`, { data });
833
1085
  }
834
1086
  async fillPdf(lib, data) {
835
1087
  const { input_path, output_path, output_pdf = false, output_type, output_file_name, form_data, forms } = data;
836
1088
  const responseType = output_pdf ? 'arraybuffer' : 'json';
837
1089
  const contentType = output_pdf ? 'application/pdf' : 'application/json';
838
- return this.request('POST', `media/library/${lib}/pdf/fill`, {
1090
+ return this.request('POST', `media/pdf/fill`, {
839
1091
  data: {
840
1092
  input_path,
841
1093
  output_path,
@@ -947,7 +1199,7 @@ class DMS extends IntegrationsBaseClient {
947
1199
  else if (to === 'excel' || to === 'xlsx') {
948
1200
  responseType = 'blob';
949
1201
  }
950
- return this.request('POST', `media/library/${lib}/convert/data`, {
1202
+ return this.request('POST', `media/convert/data`, {
951
1203
  data,
952
1204
  params: queryParams,
953
1205
  responseType,
@@ -989,7 +1241,7 @@ class DMS extends IntegrationsBaseClient {
989
1241
  */
990
1242
  async getDataInfo(lib, data, params) {
991
1243
  const { format } = params;
992
- return this.request('POST', `media/library/${lib}/convert/info`, {
1244
+ return this.request('POST', `media/convert/info`, {
993
1245
  data,
994
1246
  params: { format },
995
1247
  headers: {
@@ -1033,7 +1285,7 @@ class DMS extends IntegrationsBaseClient {
1033
1285
  */
1034
1286
  async validateData(lib, data, params) {
1035
1287
  const { format } = params;
1036
- return this.request('POST', `media/library/${lib}/convert/validate`, {
1288
+ return this.request('POST', `media/convert/validate`, {
1037
1289
  data,
1038
1290
  params: { format },
1039
1291
  headers: {
@@ -1084,7 +1336,7 @@ class DMS extends IntegrationsBaseClient {
1084
1336
  if (options === null || options === void 0 ? void 0 : options.field_order) {
1085
1337
  params.field_order = options.field_order.join(',');
1086
1338
  }
1087
- return this.request('POST', `media/library/${lib}/convert/json-to-csv`, {
1339
+ return this.request('POST', `media/convert/json-to-csv`, {
1088
1340
  params,
1089
1341
  data: jsonData,
1090
1342
  responseType: 'text',
@@ -1146,7 +1398,7 @@ class DMS extends IntegrationsBaseClient {
1146
1398
  if (options === null || options === void 0 ? void 0 : options.field_order) {
1147
1399
  params.field_order = options.field_order.join(',');
1148
1400
  }
1149
- return this.request('POST', `media/library/${lib}/convert/json-to-excel`, {
1401
+ return this.request('POST', `media/convert/json-to-excel`, {
1150
1402
  data: jsonData,
1151
1403
  params,
1152
1404
  responseType: 'blob',
@@ -1178,7 +1430,7 @@ class DMS extends IntegrationsBaseClient {
1178
1430
  * ```
1179
1431
  */
1180
1432
  async csvToJson(lib, csvData) {
1181
- return this.request('POST', `media/library/${lib}/convert/csv-to-json`, {
1433
+ return this.request('POST', `media/convert/csv-to-json`, {
1182
1434
  data: csvData,
1183
1435
  responseType: 'json',
1184
1436
  headers: {
@@ -1215,7 +1467,7 @@ class DMS extends IntegrationsBaseClient {
1215
1467
  if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1216
1468
  params.sheet_name = options.sheet_name;
1217
1469
  }
1218
- return this.request('POST', `media/library/${lib}/convert/csv-to-excel`, {
1470
+ return this.request('POST', `media/convert/csv-to-excel`, {
1219
1471
  data: csvData,
1220
1472
  params,
1221
1473
  responseType: 'blob',
@@ -1255,7 +1507,7 @@ class DMS extends IntegrationsBaseClient {
1255
1507
  if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1256
1508
  params.sheet_name = options.sheet_name;
1257
1509
  }
1258
- return this.request('POST', `media/library/${lib}/convert/excel-to-json`, {
1510
+ return this.request('POST', `media/convert/excel-to-json`, {
1259
1511
  data: excelData,
1260
1512
  params,
1261
1513
  responseType: 'json',
@@ -1299,7 +1551,7 @@ class DMS extends IntegrationsBaseClient {
1299
1551
  if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1300
1552
  params.sheet_name = options.sheet_name;
1301
1553
  }
1302
- return this.request('POST', `media/library/${lib}/convert/excel-to-csv`, {
1554
+ return this.request('POST', `media/convert/excel-to-csv`, {
1303
1555
  data: excelData,
1304
1556
  params,
1305
1557
  responseType: 'text',
@@ -1311,7 +1563,7 @@ class DMS extends IntegrationsBaseClient {
1311
1563
  async request(method, endpoint, params) {
1312
1564
  return await this.client.request({
1313
1565
  method: method,
1314
- url: `/v2/dms/${endpoint}`,
1566
+ url: `/v3/dms/${endpoint}`,
1315
1567
  ...params
1316
1568
  });
1317
1569
  }
@@ -1325,7 +1577,7 @@ class DMS extends IntegrationsBaseClient {
1325
1577
  }
1326
1578
 
1327
1579
  class SerbiaUtil extends IntegrationsBaseClient {
1328
- async nsbSearch(params) {
1580
+ async nbsSearch(params) {
1329
1581
  return await this.services("GET", "nbs/search", { params });
1330
1582
  }
1331
1583
  async getReceiptFromUrl(url, source) {
@@ -1419,4 +1671,4 @@ class Integrations extends IntegrationsBaseClient {
1419
1671
  }
1420
1672
  }
1421
1673
 
1422
- export { APIUser, Apps, Component, ComponentUtils, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Payments, Ratchet, Roles, Sandbox, SerbiaUtil, System, Thunder, Users as User, VPFR, Workflow, Platform as default };
1674
+ export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Payments, Project, Ratchet, Sandbox, SerbiaUtil, System, Thunder, Users as User, VPFR, Workflow, Platform as default };