@ptkl/sdk 1.14.0 → 1.16.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.
@@ -1,5 +1,5 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
- import { UserClaims, UserModel, Role, CreateRoleRequest, EditRoleRequest, RoleModel, Permission } from "../types/users";
2
+ import { UserClaims, UserModel, Role, CreateRoleRequest, EditRoleRequest, RoleModel, Permission, Permissions } from "../types/users";
3
3
  import { AxiosResponse } from "axios";
4
4
  export default class Users extends PlatformBaseClient {
5
5
  auth(username: string, password: string, project: string): Promise<AxiosResponse<any>>;
@@ -28,9 +28,28 @@ export default class Users extends PlatformBaseClient {
28
28
  */
29
29
  editProfile(data: any): Promise<AxiosResponse<any>>;
30
30
  /**
31
- * Get user permissions
31
+ * Get the current token's permissions.
32
+ *
33
+ * Returns the resolved permission set carried by the calling token. For a
34
+ * forge actor token this is the scoped intersection minted at launch time —
35
+ * see `getPrincipalPermissions()` for the underlying user's full set.
32
36
  */
33
- getPermissions(): Promise<AxiosResponse<Permission[]>>;
37
+ getPermissions(): Promise<AxiosResponse<Permissions>>;
38
+ /**
39
+ * Get the FULL permissions of the user the current token is acting on behalf
40
+ * of (the "principal").
41
+ *
42
+ * When a forge app runs under an actor token, `getPermissions()` returns only
43
+ * the token's scoped permissions — the intersection of the app's declared
44
+ * runtime permissions and the user's permissions. This instead returns the
45
+ * complete permission set of the underlying user, so the app can check what
46
+ * that user is actually allowed to do, independent of what the app itself was
47
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
48
+ *
49
+ * For a normal user session (no actor token) it returns the caller's own
50
+ * permissions, identical to `getPermissions()`'s scope.
51
+ */
52
+ getPrincipalPermissions(): Promise<AxiosResponse<Permissions>>;
34
53
  /**
35
54
  * Get list of available permissions
36
55
  */
@@ -19550,11 +19550,32 @@ class Users extends PlatformBaseClient {
19550
19550
  }
19551
19551
  // Permissions & Roles
19552
19552
  /**
19553
- * Get user permissions
19553
+ * Get the current token's permissions.
19554
+ *
19555
+ * Returns the resolved permission set carried by the calling token. For a
19556
+ * forge actor token this is the scoped intersection minted at launch time —
19557
+ * see `getPrincipalPermissions()` for the underlying user's full set.
19554
19558
  */
19555
19559
  async getPermissions() {
19556
19560
  return await this.client.get("/v1/user/role/permissions");
19557
19561
  }
19562
+ /**
19563
+ * Get the FULL permissions of the user the current token is acting on behalf
19564
+ * of (the "principal").
19565
+ *
19566
+ * When a forge app runs under an actor token, `getPermissions()` returns only
19567
+ * the token's scoped permissions — the intersection of the app's declared
19568
+ * runtime permissions and the user's permissions. This instead returns the
19569
+ * complete permission set of the underlying user, so the app can check what
19570
+ * that user is actually allowed to do, independent of what the app itself was
19571
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
19572
+ *
19573
+ * For a normal user session (no actor token) it returns the caller's own
19574
+ * permissions, identical to `getPermissions()`'s scope.
19575
+ */
19576
+ async getPrincipalPermissions() {
19577
+ return await this.client.get("/v1/user/role/principal-permissions");
19578
+ }
19558
19579
  /**
19559
19580
  * Get list of available permissions
19560
19581
  */
@@ -20258,6 +20279,7 @@ class IntegrationsBaseClient extends BaseClient {
20258
20279
  // @ts-ignore
20259
20280
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20260
20281
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20282
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
20261
20283
  if (isBrowser) {
20262
20284
  if (sessionStorage.getItem('protokol_context') === 'forge') {
20263
20285
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -21122,36 +21144,41 @@ class VPFR extends IntegrationsBaseClient {
21122
21144
  }
21123
21145
 
21124
21146
  class Payments extends IntegrationsBaseClient {
21147
+ // FIXME: No backend route exists for listing/searching transactions (neither
21148
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
21149
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
21150
+ // rather than being "fixed" to another guessed path that would still 404.
21151
+ // Do not call this method until a corresponding backend route is added.
21125
21152
  async getTransactions(userId, params) {
21126
21153
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
21127
21154
  params,
21128
21155
  });
21129
21156
  }
21130
- async getTransaction(provider, userId, transactionId) {
21131
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
21157
+ async getTransaction(provider, transactionId) {
21158
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
21132
21159
  params: { transactionId },
21133
21160
  });
21134
21161
  }
21135
21162
  async settings(provider) {
21136
21163
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
21137
21164
  }
21138
- async deactivatePaymentLink(provider, user, transactionId) {
21139
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
21165
+ async deactivatePaymentLink(provider, transactionId) {
21166
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
21140
21167
  }
21141
- async voidTransaction(provider, user, transactionId) {
21142
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
21168
+ async voidTransaction(provider, transactionId) {
21169
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
21143
21170
  }
21144
- async refund(provider, user, transactionId) {
21145
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
21171
+ async refund(provider, transactionId) {
21172
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
21146
21173
  }
21147
- async getPaymentLink(provider, user, options) {
21148
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
21174
+ async getPaymentLink(provider, options) {
21175
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
21149
21176
  }
21150
- async getTokenRequestLink(provider, user, options) {
21151
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
21177
+ async getTokenRequestLink(provider, options) {
21178
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
21152
21179
  }
21153
- async directPayUsingToken(provider, user, options) {
21154
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
21180
+ async directPayUsingToken(provider, options) {
21181
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
21155
21182
  }
21156
21183
  }
21157
21184
 
@@ -581,11 +581,32 @@ class Users extends PlatformBaseClient {
581
581
  }
582
582
  // Permissions & Roles
583
583
  /**
584
- * Get user permissions
584
+ * Get the current token's permissions.
585
+ *
586
+ * Returns the resolved permission set carried by the calling token. For a
587
+ * forge actor token this is the scoped intersection minted at launch time —
588
+ * see `getPrincipalPermissions()` for the underlying user's full set.
585
589
  */
586
590
  async getPermissions() {
587
591
  return await this.client.get("/v1/user/role/permissions");
588
592
  }
593
+ /**
594
+ * Get the FULL permissions of the user the current token is acting on behalf
595
+ * of (the "principal").
596
+ *
597
+ * When a forge app runs under an actor token, `getPermissions()` returns only
598
+ * the token's scoped permissions — the intersection of the app's declared
599
+ * runtime permissions and the user's permissions. This instead returns the
600
+ * complete permission set of the underlying user, so the app can check what
601
+ * that user is actually allowed to do, independent of what the app itself was
602
+ * granted. The token scope is unchanged: this exposes knowledge, not capability.
603
+ *
604
+ * For a normal user session (no actor token) it returns the caller's own
605
+ * permissions, identical to `getPermissions()`'s scope.
606
+ */
607
+ async getPrincipalPermissions() {
608
+ return await this.client.get("/v1/user/role/principal-permissions");
609
+ }
589
610
  /**
590
611
  * Get list of available permissions
591
612
  */
@@ -1289,6 +1310,7 @@ class IntegrationsBaseClient extends BaseClient {
1289
1310
  // @ts-ignore
1290
1311
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1291
1312
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1313
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
1292
1314
  if (isBrowser) {
1293
1315
  if (sessionStorage.getItem('protokol_context') === 'forge') {
1294
1316
  headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
@@ -2153,36 +2175,41 @@ class VPFR extends IntegrationsBaseClient {
2153
2175
  }
2154
2176
 
2155
2177
  class Payments extends IntegrationsBaseClient {
2178
+ // FIXME: No backend route exists for listing/searching transactions (neither
2179
+ // monri.route.ts nor wspay.route.ts under karadjordje/src/routes/v1/payments/
2180
+ // expose a "list" endpoint). This method's URL is left as-is (still broken)
2181
+ // rather than being "fixed" to another guessed path that would still 404.
2182
+ // Do not call this method until a corresponding backend route is added.
2156
2183
  async getTransactions(userId, params) {
2157
2184
  return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
2158
2185
  params,
2159
2186
  });
2160
2187
  }
2161
- async getTransaction(provider, userId, transactionId) {
2162
- return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
2188
+ async getTransaction(provider, transactionId) {
2189
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/getTransaction`, {
2163
2190
  params: { transactionId },
2164
2191
  });
2165
2192
  }
2166
2193
  async settings(provider) {
2167
2194
  return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
2168
2195
  }
2169
- async deactivatePaymentLink(provider, user, transactionId) {
2170
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
2196
+ async deactivatePaymentLink(provider, transactionId) {
2197
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/deactivate/${transactionId}`);
2171
2198
  }
2172
- async voidTransaction(provider, user, transactionId) {
2173
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
2199
+ async voidTransaction(provider, transactionId) {
2200
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/void/${transactionId}`);
2174
2201
  }
2175
- async refund(provider, user, transactionId) {
2176
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
2202
+ async refund(provider, transactionId) {
2203
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/refund/${transactionId}`);
2177
2204
  }
2178
- async getPaymentLink(provider, user, options) {
2179
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
2205
+ async getPaymentLink(provider, options) {
2206
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getPaymentLink`, options);
2180
2207
  }
2181
- async getTokenRequestLink(provider, user, options) {
2182
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
2208
+ async getTokenRequestLink(provider, options) {
2209
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/getTokenRequestLink`, options);
2183
2210
  }
2184
- async directPayUsingToken(provider, user, options) {
2185
- return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
2211
+ async directPayUsingToken(provider, options) {
2212
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/directPayUsingToken`, options);
2186
2213
  }
2187
2214
  }
2188
2215
 
@@ -409,6 +409,7 @@ type SetupData = {
409
409
  is_public?: boolean;
410
410
  icon?: string;
411
411
  settings?: Settings;
412
+ force_override?: boolean;
412
413
  };
413
414
  type ComponentCreateResponse = ComponentListItem;
414
415
  export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, UpdateOperators, UpdateAggregate, ModelUpdateData, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, Extension, Policy, FieldAccessConfig, TemplatesDist, SetupData, ComponentCreateResponse, };
@@ -65,3 +65,13 @@ export interface Permission {
65
65
  action: string;
66
66
  role_uuid: string;
67
67
  }
68
+ /**
69
+ * Resolved RBAC permission set for a user on the current project.
70
+ * Matches the dashboard `models.Permissions` response shape returned by
71
+ * `GET /v1/user/role/permissions` and `GET /v1/user/role/principal-permissions`.
72
+ */
73
+ export interface Permissions {
74
+ is_admin: boolean;
75
+ roles: string[];
76
+ permissions: string[];
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",