@lessly/sdk-app 94.0.0 → 94.1.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -48
  2. package/dist/_types/gen/client.gen.d.ts +6 -42
  3. package/dist/_types/gen/manifest.gen.d.ts +1 -1
  4. package/dist/_types/gen/organization/index.d.ts +1 -1
  5. package/dist/_types/gen/organization/queryOptions.gen.d.ts +12 -8
  6. package/dist/_types/gen/types.gen.d.ts +1379 -9754
  7. package/dist/_types/index.d.ts +1 -1
  8. package/dist/_types/runtime/errors.d.ts +13 -0
  9. package/dist/index.cjs +61 -263
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +11506 -29
  12. package/dist/index.js.map +1 -1
  13. package/dist/organization/index.cjs +15 -10
  14. package/dist/organization/index.cjs.map +1 -1
  15. package/dist/organization/index.js +13 -9
  16. package/dist/organization/index.js.map +1 -1
  17. package/docs/README.md +1 -0
  18. package/docs/recipes/entitlements.md +96 -0
  19. package/docs/recipes/sdk-usage.md +5 -0
  20. package/package.json +2 -12
  21. package/src/gen/bindings.gen.ts +32 -246
  22. package/src/gen/client.gen.ts +11 -79
  23. package/src/gen/manifest.gen.ts +8 -27
  24. package/src/gen/organization/index.ts +1 -1
  25. package/src/gen/organization/queryOptions.gen.ts +17 -11
  26. package/src/gen/types.gen.ts +1495 -9452
  27. package/dist/_types/gen/playground/connect.gen.d.ts +0 -3
  28. package/dist/_types/gen/playground/index.d.ts +0 -3
  29. package/dist/_types/gen/playground/queryOptions.gen.d.ts +0 -70
  30. package/dist/chunk-HIAGROHK.js +0 -11695
  31. package/dist/chunk-HIAGROHK.js.map +0 -1
  32. package/dist/playground/index.cjs +0 -106
  33. package/dist/playground/index.cjs.map +0 -1
  34. package/dist/playground/index.d.cts +0 -1
  35. package/dist/playground/index.d.ts +0 -1
  36. package/dist/playground/index.js +0 -78
  37. package/dist/playground/index.js.map +0 -1
  38. package/src/gen/playground/connect.gen.ts +0 -9
  39. package/src/gen/playground/index.ts +0 -4
  40. package/src/gen/playground/queryOptions.gen.ts +0 -119
@@ -1,7 +1,7 @@
1
1
  export { createLesslyApp } from './runtime/createLesslyApp.js';
2
2
  export type { LesslyClientBase } from './runtime/createLesslyApp.js';
3
3
  export { connectStream } from './runtime/connectStream.js';
4
- export { LesslyApiError, isAccessDenied } from './runtime/errors.js';
4
+ export { LesslyApiError, isAccessDenied, isEntitlementError, upgradeUrl } from './runtime/errors.js';
5
5
  export { accessReason } from './runtime/access-reason.js';
6
6
  export { platformApiBaseUrl } from './runtime/platform-base-url.js';
7
7
  export { operations } from './runtime/operations.js';
@@ -16,3 +16,16 @@ export declare function parseErrorBody(body: unknown, status: number): LesslyApi
16
16
  * report false there and an App would render a red crash for an ordinary permission refusal.
17
17
  */
18
18
  export declare function isAccessDenied(err: unknown): boolean;
19
+ /**
20
+ * True iff `err` is billing refusing the call over the organization's plan (trial cap reached,
21
+ * a class closed on a trial, billing or budget paused). Inside the Workspace shell the shell
22
+ * shows the refusal itself: an App uses this to render nothing, not a second error.
23
+ */
24
+ export declare function isEntitlementError(err: unknown): boolean;
25
+ /**
26
+ * The refusal's `upgrade_url` — the Workspace billing page with the upgrade offer open for the
27
+ * refused organization — or null when `err` is not an entitlement refusal or carries no usable
28
+ * URL. For Apps the shell cannot see (standalone, or calling through their own `fetch`). Only an
29
+ * absolute http(s) URL is returned: the value is meant to be navigated to.
30
+ */
31
+ export declare function upgradeUrl(err: unknown): string | null;
package/dist/index.cjs CHANGED
@@ -33,6 +33,27 @@ function isAccessDenied(err) {
33
33
  const { status, code } = err;
34
34
  return status === 403 && typeof code === "string" && ACCESS_DENIED_CODES.has(code);
35
35
  }
36
+ var ENTITLEMENT_ERRORS = /* @__PURE__ */ new Set(["entitlement_exhausted", "entitlement_unavailable"]);
37
+ function entitlementRefusal(err) {
38
+ if (typeof err !== "object" || err === null) return null;
39
+ const { status, body } = err;
40
+ if (status !== 402 || typeof body !== "object" || body === null) return null;
41
+ const { error } = body;
42
+ return typeof error === "string" && ENTITLEMENT_ERRORS.has(error) ? body : null;
43
+ }
44
+ function isEntitlementError(err) {
45
+ return entitlementRefusal(err) !== null;
46
+ }
47
+ function upgradeUrl(err) {
48
+ const url = entitlementRefusal(err)?.upgrade_url;
49
+ if (typeof url !== "string") return null;
50
+ try {
51
+ const { protocol } = new URL(url);
52
+ return protocol === "https:" || protocol === "http:" ? url : null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
36
57
 
37
58
  // src/runtime/csrf.ts
38
59
  var CSRF_COOKIES = ["lepsto_csrf", "lessly_csrf"];
@@ -2013,10 +2034,6 @@ var bindings = {
2013
2034
  {
2014
2035
  "in": "body",
2015
2036
  "name": "media"
2016
- },
2017
- {
2018
- "in": "body",
2019
- "name": "targets"
2020
2037
  }
2021
2038
  ],
2022
2039
  "path": "/content/posts",
@@ -2085,10 +2102,6 @@ var bindings = {
2085
2102
  {
2086
2103
  "in": "body",
2087
2104
  "name": "media"
2088
- },
2089
- {
2090
- "in": "body",
2091
- "name": "targets"
2092
2105
  }
2093
2106
  ],
2094
2107
  "path": "/content/posts/:id",
@@ -2244,6 +2257,10 @@ var bindings = {
2244
2257
  "in": "body",
2245
2258
  "name": "channelId"
2246
2259
  },
2260
+ {
2261
+ "in": "body",
2262
+ "name": "text"
2263
+ },
2247
2264
  {
2248
2265
  "in": "body",
2249
2266
  "name": "idempotencyKey"
@@ -2299,6 +2316,10 @@ var bindings = {
2299
2316
  "in": "body",
2300
2317
  "name": "scheduledAt"
2301
2318
  },
2319
+ {
2320
+ "in": "body",
2321
+ "name": "text"
2322
+ },
2302
2323
  {
2303
2324
  "in": "body",
2304
2325
  "name": "idempotencyKey"
@@ -6154,47 +6175,48 @@ var bindings = {
6154
6175
  "readOnly": true
6155
6176
  }
6156
6177
  },
6157
- "billing-budgets": {
6158
- "get": {
6159
- "level": "read",
6160
- "method": "GET",
6161
- "operationKey": "organization_billing_budgets_get",
6162
- "path": "/governance/api/v1/billing/budgets",
6163
- "readOnly": true
6164
- }
6165
- },
6166
- "billing-caps": {
6178
+ "billing-budget": {
6167
6179
  "clear": {
6168
6180
  "level": "write",
6169
6181
  "method": "DELETE",
6170
- "operationKey": "organization_billing_caps_clear",
6171
- "params": [
6172
- {
6173
- "in": "body",
6174
- "name": "productId"
6175
- }
6176
- ],
6177
- "path": "/governance/api/v1/billing/budgets/cap",
6182
+ "operationKey": "organization_billing_budget_clear",
6183
+ "path": "/governance/api/v1/billing/budgets",
6184
+ "readOnly": false
6185
+ },
6186
+ "resume": {
6187
+ "level": "write",
6188
+ "method": "POST",
6189
+ "operationKey": "organization_billing_budget_resume",
6190
+ "path": "/governance/api/v1/billing/budgets/resume",
6178
6191
  "readOnly": false
6179
6192
  },
6180
6193
  "set": {
6181
6194
  "level": "write",
6182
6195
  "method": "PUT",
6183
- "operationKey": "organization_billing_caps_set",
6196
+ "operationKey": "organization_billing_budget_set",
6184
6197
  "params": [
6185
6198
  {
6186
6199
  "in": "body",
6187
- "name": "productId"
6200
+ "name": "amount_minor"
6188
6201
  },
6189
6202
  {
6190
6203
  "in": "body",
6191
- "name": "cap_minor"
6204
+ "name": "action"
6192
6205
  }
6193
6206
  ],
6194
- "path": "/governance/api/v1/billing/budgets/cap",
6207
+ "path": "/governance/api/v1/billing/budgets",
6195
6208
  "readOnly": false
6196
6209
  }
6197
6210
  },
6211
+ "billing-budgets": {
6212
+ "get": {
6213
+ "level": "read",
6214
+ "method": "GET",
6215
+ "operationKey": "organization_billing_budgets_get",
6216
+ "path": "/governance/api/v1/billing/budgets",
6217
+ "readOnly": true
6218
+ }
6219
+ },
6198
6220
  "bindings": {
6199
6221
  "list": {
6200
6222
  "level": "read",
@@ -7621,213 +7643,6 @@ var bindings = {
7621
7643
  }
7622
7644
  }
7623
7645
  },
7624
- "playground": {
7625
- "analytics": {
7626
- "overview": {
7627
- "level": "read",
7628
- "method": "POST",
7629
- "operationKey": "playground_analytics_overview",
7630
- "params": [
7631
- {
7632
- "in": "body",
7633
- "name": "limit"
7634
- }
7635
- ],
7636
- "path": "/playground/analytics/overview",
7637
- "readOnly": true
7638
- }
7639
- },
7640
- "billing": {
7641
- "entitlements": {
7642
- "level": "read",
7643
- "method": "POST",
7644
- "operationKey": "playground_billing_entitlements",
7645
- "path": "/playground/billing/entitlements",
7646
- "readOnly": true
7647
- },
7648
- "record-usage": {
7649
- "level": "write",
7650
- "method": "POST",
7651
- "operationKey": "playground_billing_record-usage",
7652
- "params": [
7653
- {
7654
- "in": "body",
7655
- "name": "value"
7656
- }
7657
- ],
7658
- "path": "/playground/billing/usage",
7659
- "readOnly": false
7660
- }
7661
- },
7662
- "clickup": {
7663
- "create-task": {
7664
- "level": "write",
7665
- "method": "POST",
7666
- "operationKey": "playground_clickup_create-task",
7667
- "params": [
7668
- {
7669
- "in": "body",
7670
- "name": "listId"
7671
- },
7672
- {
7673
- "in": "body",
7674
- "name": "name"
7675
- }
7676
- ],
7677
- "path": "/playground/clickup/tasks",
7678
- "readOnly": false
7679
- },
7680
- "get-last-webhook": {
7681
- "level": "read",
7682
- "method": "GET",
7683
- "operationKey": "playground_clickup_get-last-webhook",
7684
- "path": "/playground/clickup/webhooks/last",
7685
- "readOnly": true
7686
- },
7687
- "get-overview": {
7688
- "level": "read",
7689
- "method": "GET",
7690
- "operationKey": "playground_clickup_get-overview",
7691
- "path": "/playground/clickup/overview",
7692
- "readOnly": true
7693
- }
7694
- },
7695
- "echo": {
7696
- "ping": {
7697
- "level": "read",
7698
- "method": "POST",
7699
- "operationKey": "playground_echo_ping",
7700
- "params": [
7701
- {
7702
- "in": "body",
7703
- "name": "message"
7704
- }
7705
- ],
7706
- "path": "/playground/echo/ping",
7707
- "readOnly": true
7708
- }
7709
- },
7710
- "gdrive": {
7711
- "get-last-change": {
7712
- "level": "read",
7713
- "method": "GET",
7714
- "operationKey": "playground_gdrive_get-last-change",
7715
- "path": "/playground/gdrive/changes/last",
7716
- "readOnly": true
7717
- },
7718
- "read-file": {
7719
- "level": "read",
7720
- "method": "POST",
7721
- "operationKey": "playground_gdrive_read-file",
7722
- "params": [
7723
- {
7724
- "in": "body",
7725
- "name": "fileId"
7726
- }
7727
- ],
7728
- "path": "/playground/gdrive/file",
7729
- "readOnly": true
7730
- }
7731
- },
7732
- "googleads": {
7733
- "read-customer": {
7734
- "level": "read",
7735
- "method": "POST",
7736
- "operationKey": "playground_googleads_read-customer",
7737
- "path": "/playground/googleads/customer",
7738
- "readOnly": true
7739
- }
7740
- },
7741
- "lifecycle": {
7742
- "get-state": {
7743
- "level": "read",
7744
- "method": "GET",
7745
- "operationKey": "playground_lifecycle_get-state",
7746
- "path": "/playground/lifecycle/state",
7747
- "readOnly": true
7748
- },
7749
- "list-events": {
7750
- "level": "read",
7751
- "method": "GET",
7752
- "operationKey": "playground_lifecycle_list-events",
7753
- "path": "/playground/lifecycle/events",
7754
- "readOnly": true
7755
- }
7756
- },
7757
- "webhook": {
7758
- "get-last": {
7759
- "level": "read",
7760
- "method": "GET",
7761
- "operationKey": "playground_webhook_get-last",
7762
- "path": "/playground/webhooks/last",
7763
- "readOnly": true
7764
- }
7765
- },
7766
- "workflow": {
7767
- "echo": {
7768
- "level": "write",
7769
- "method": "POST",
7770
- "operationKey": "playground_workflow_echo",
7771
- "params": [
7772
- {
7773
- "in": "body",
7774
- "name": "note"
7775
- },
7776
- {
7777
- "in": "body",
7778
- "name": "tags"
7779
- }
7780
- ],
7781
- "path": "/playground/workflow/echo",
7782
- "readOnly": false
7783
- },
7784
- "echo-list": {
7785
- "level": "read",
7786
- "method": "GET",
7787
- "operationKey": "playground_workflow_echo-list",
7788
- "path": "/playground/workflow/echoes",
7789
- "readOnly": true
7790
- },
7791
- "ping": {
7792
- "level": "write",
7793
- "method": "POST",
7794
- "operationKey": "playground_workflow_ping",
7795
- "params": [
7796
- {
7797
- "in": "body",
7798
- "name": "kind"
7799
- }
7800
- ],
7801
- "path": "/playground/workflow/ping",
7802
- "readOnly": false
7803
- },
7804
- "subjects-list": {
7805
- "level": "read",
7806
- "method": "GET",
7807
- "operationKey": "playground_workflow_subjects-list",
7808
- "params": [
7809
- {
7810
- "in": "query",
7811
- "name": "last_activity_before"
7812
- },
7813
- {
7814
- "in": "query",
7815
- "name": "last_activity_after"
7816
- },
7817
- {
7818
- "in": "query",
7819
- "name": "limit"
7820
- },
7821
- {
7822
- "in": "query",
7823
- "name": "cursor"
7824
- }
7825
- ],
7826
- "path": "/playground/workflow/subjects",
7827
- "readOnly": true
7828
- }
7829
- }
7830
- },
7831
7646
  "realtime": {
7832
7647
  "archive": {
7833
7648
  "export": {
@@ -12211,9 +12026,10 @@ var operations = {
12211
12026
  "observe_webhooks_rotate_secret": "admin",
12212
12027
  "observe_webhooks_update": "write",
12213
12028
  "organization_auth_me": "read",
12029
+ "organization_billing_budget_clear": "write",
12030
+ "organization_billing_budget_resume": "write",
12031
+ "organization_billing_budget_set": "write",
12214
12032
  "organization_billing_budgets_get": "read",
12215
- "organization_billing_caps_clear": "write",
12216
- "organization_billing_caps_set": "write",
12217
12033
  "organization_bindings_list": "read",
12218
12034
  "organization_clickup_install": "read",
12219
12035
  "organization_clickup_list-installations": "read",
@@ -12300,23 +12116,6 @@ var operations = {
12300
12116
  "organization_support_threads_list": "read",
12301
12117
  "organization_x_install": "read",
12302
12118
  "organization_youtube_install": "read",
12303
- "playground_analytics_overview": "read",
12304
- "playground_billing_entitlements": "read",
12305
- "playground_billing_record-usage": "write",
12306
- "playground_clickup_create-task": "write",
12307
- "playground_clickup_get-last-webhook": "read",
12308
- "playground_clickup_get-overview": "read",
12309
- "playground_echo_ping": "read",
12310
- "playground_gdrive_get-last-change": "read",
12311
- "playground_gdrive_read-file": "read",
12312
- "playground_googleads_read-customer": "read",
12313
- "playground_lifecycle_get-state": "read",
12314
- "playground_lifecycle_list-events": "read",
12315
- "playground_webhook_get-last": "read",
12316
- "playground_workflow_echo": "write",
12317
- "playground_workflow_echo-list": "read",
12318
- "playground_workflow_ping": "write",
12319
- "playground_workflow_subjects-list": "read",
12320
12119
  "realtime_archive_export": "admin",
12321
12120
  "realtime_archive_export_status": "read",
12322
12121
  "realtime_archive_get": "read",
@@ -12546,10 +12345,10 @@ var compositions = {
12546
12345
  "brain_memory_update": { "pii": ["input.content"], "label": "Update memory", "options": { "memory_id": "brain_memory_list" } },
12547
12346
  "brain_usage_report": { "label": "Get usage report" },
12548
12347
  "content_metrics_post_series": { "label": "Read post metrics", "options": { "id": "content_publications_list" } },
12549
- "content_posts_create": { "pii": ["output.author", "output.text", "output.media", "output.targets"], "label": "Create draft post" },
12550
- "content_posts_get": { "pii": ["output.author", "output.text", "output.media", "output.targets"], "label": "Get post", "options": { "id": "content_posts_list" } },
12551
- "content_posts_list": { "pii": ["output.posts[].author", "output.posts[].text", "output.posts[].media", "output.posts[].targets"], "label": "List posts" },
12552
- "content_posts_submit": { "pii": ["output.author", "output.text", "output.media", "output.targets"], "label": "Submit post for approval", "options": { "id": "content_posts_list" } },
12348
+ "content_posts_create": { "pii": ["output.author", "output.text", "output.media"], "label": "Create draft post" },
12349
+ "content_posts_get": { "pii": ["output.author", "output.text", "output.media"], "label": "Get post", "options": { "id": "content_posts_list" } },
12350
+ "content_posts_list": { "pii": ["output.posts[].author", "output.posts[].text", "output.posts[].media"], "label": "List posts" },
12351
+ "content_posts_submit": { "pii": ["output.author", "output.text", "output.media"], "label": "Submit post for approval", "options": { "id": "content_posts_list" } },
12553
12352
  "content_publications_cancel": { "label": "Cancel publication", "options": { "id": "content_publications_list" } },
12554
12353
  "content_publications_publish": { "label": "Publish now", "options": { "postId": "content_posts_list", "channelId": "content_channels_list" }, "completion_event": "content/publication.settled" },
12555
12354
  "content_publications_schedule": { "label": "Schedule publication", "options": { "postId": "content_posts_list", "channelId": "content_channels_list" }, "completion_event": "content/publication.settled" },
@@ -12599,9 +12398,6 @@ var compositions = {
12599
12398
  "mail_template_unarchive": { "label": "Unarchive template", "options": { "id": "mail_template_list" } },
12600
12399
  "mail_template_update": { "label": "Update template", "options": { "id": "mail_template_list" } },
12601
12400
  "mail_usage_get": { "label": "Get usage" },
12602
- "playground_workflow_echo": { "pii": ["input.note", "output.note"], "label": "Store workflow echo", "completion_event": "playground/workflow.echoed" },
12603
- "playground_workflow_ping": { "label": "Fire workflow ping", "completion_event": "playground/workflow.ping" },
12604
- "playground_workflow_subjects-list": { "pii": ["output.items[].display_name"], "label": "List workflow subjects" },
12605
12401
  "support_agent_create": { "pii": ["input.lesslyUserId", "output.lesslyUserId"], "label": "Create agent" },
12606
12402
  "support_agent_get": { "pii": ["output.lesslyUserId"], "label": "Get agent", "options": { "id": "support_agent_list" } },
12607
12403
  "support_agent_list": { "pii": ["output.agents[].lesslyUserId"], "label": "List agents" },
@@ -12965,7 +12761,9 @@ exports.compositions = compositions2;
12965
12761
  exports.connectStream = connectStream;
12966
12762
  exports.createLesslyApp = createLesslyApp;
12967
12763
  exports.isAccessDenied = isAccessDenied;
12764
+ exports.isEntitlementError = isEntitlementError;
12968
12765
  exports.operations = operations2;
12969
12766
  exports.platformApiBaseUrl = platformApiBaseUrl;
12767
+ exports.upgradeUrl = upgradeUrl;
12970
12768
  //# sourceMappingURL=index.cjs.map
12971
12769
  //# sourceMappingURL=index.cjs.map