@deepraxis/sdk 0.1.1-dev.bc4b5b7 → 0.1.1-dev.bff6020
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/METHODS.md +175 -13
- package/README.md +1 -1
- package/dist/core/credentials.d.ts +12 -3
- package/dist/core/credentials.js +22 -2
- package/dist/core/transport.d.ts +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +347 -23
- package/dist/generated/sdk.gen.js +2004 -1088
- package/dist/generated/types.gen.d.ts +32427 -26061
- package/dist/operations.generated.d.ts +35 -19588
- package/dist/operations.generated.js +8611 -6615
- package/dist/resources.generated.d.ts +102 -9
- package/dist/resources.generated.js +102 -8
- package/package.json +1 -1
package/METHODS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK methods
|
|
2
2
|
|
|
3
|
-
Generated by `bun run generate`.
|
|
3
|
+
Generated by `bun run generate`. 673 HTTP operations, plus product aliases. Version segments and path parameters are omitted from resource names. Inputs use typed `{ path, query, body, headers }` options. Collections form nested resource objects; POST actions retain their verb. Naming rules are documented in `scripts/resources.ts`; semantic exceptions and aliases with reasons are in `scripts/naming-overrides.ts`.
|
|
4
4
|
|
|
5
5
|
`always` returns an AsyncIterable; `optional` streams with `{ stream: true }`; `yes` pagination returns a Page. Only `{ data, next_cursor }` + `cursor` query contracts are automatically paginated.
|
|
6
6
|
|
|
@@ -878,12 +878,78 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
878
878
|
|
|
879
879
|
## devops
|
|
880
880
|
|
|
881
|
+
### devops.environments.checkpoints
|
|
882
|
+
|
|
883
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
884
|
+
|---|---|---|---|---|
|
|
885
|
+
| list | GET | `/devops/v1/environments/{id}/checkpoints` | no | no |
|
|
886
|
+
|
|
887
|
+
### devops.flags
|
|
888
|
+
|
|
889
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
890
|
+
|---|---|---|---|---|
|
|
891
|
+
| archive | POST | `/devops/v1/flags/{id}:archive` | no | no |
|
|
892
|
+
| conclude | POST | `/devops/v1/flags/{id}:conclude` | no | no |
|
|
893
|
+
| retrieve | GET | `/devops/v1/flags/{id}` | no | no |
|
|
894
|
+
| update | PATCH | `/devops/v1/flags/{id}` | no | no |
|
|
895
|
+
|
|
896
|
+
### devops.flags.environments
|
|
897
|
+
|
|
898
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
899
|
+
|---|---|---|---|---|
|
|
900
|
+
| update | PATCH | `/devops/v1/flags/{id}/environments/{environment}` | no | no |
|
|
901
|
+
|
|
902
|
+
### devops.progressiveRollouts
|
|
903
|
+
|
|
904
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
905
|
+
|---|---|---|---|---|
|
|
906
|
+
| create | POST | `/devops/v1/progressive-rollouts` | no | no |
|
|
907
|
+
| pause | POST | `/devops/v1/progressive-rollouts/{id}:pause` | no | no |
|
|
908
|
+
| resume | POST | `/devops/v1/progressive-rollouts/{id}:resume` | no | no |
|
|
909
|
+
| retrieve | GET | `/devops/v1/progressive-rollouts/{id}` | no | no |
|
|
910
|
+
| rollback | POST | `/devops/v1/progressive-rollouts/{id}:rollback` | no | no |
|
|
911
|
+
|
|
881
912
|
### devops.projects
|
|
882
913
|
|
|
883
914
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
884
915
|
|---|---|---|---|---|
|
|
916
|
+
| list | GET | `/devops/v1/projects` | no | no |
|
|
917
|
+
| retrieve | GET | `/devops/v1/projects/{id}` | no | no |
|
|
885
918
|
| retrieveTestCatalog | GET | `/devops/v1/projects/{project}/test-catalog` | no | no |
|
|
886
919
|
|
|
920
|
+
### devops.projects.environments
|
|
921
|
+
|
|
922
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
923
|
+
|---|---|---|---|---|
|
|
924
|
+
| list | GET | `/devops/v1/projects/{project}/environments` | no | no |
|
|
925
|
+
|
|
926
|
+
### devops.projects.flags
|
|
927
|
+
|
|
928
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
929
|
+
|---|---|---|---|---|
|
|
930
|
+
| create | POST | `/devops/v1/projects/{project}/flags` | no | no |
|
|
931
|
+
| list | GET | `/devops/v1/projects/{project}/flags` | no | no |
|
|
932
|
+
|
|
933
|
+
### devops.projects.promotions
|
|
934
|
+
|
|
935
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
936
|
+
|---|---|---|---|---|
|
|
937
|
+
| list | GET | `/devops/v1/projects/{project}/promotions` | no | no |
|
|
938
|
+
|
|
939
|
+
### devops.projects.releases
|
|
940
|
+
|
|
941
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
942
|
+
|---|---|---|---|---|
|
|
943
|
+
| create | POST | `/devops/v1/projects/{project}/releases` | no | no |
|
|
944
|
+
| list | GET | `/devops/v1/projects/{project}/releases` | no | no |
|
|
945
|
+
|
|
946
|
+
### devops.projects.targets
|
|
947
|
+
|
|
948
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
949
|
+
|---|---|---|---|---|
|
|
950
|
+
| list | GET | `/devops/v1/projects/{project}/targets` | no | no |
|
|
951
|
+
| refresh | POST | `/devops/v1/projects/{project}/targets:refresh` | no | no |
|
|
952
|
+
|
|
887
953
|
### devops.projects.testCases
|
|
888
954
|
|
|
889
955
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -916,6 +982,36 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
916
982
|
|---|---|---|---|---|
|
|
917
983
|
| list | GET | `/devops/v1/projects/{project}/test-suites` | no | no |
|
|
918
984
|
|
|
985
|
+
### devops.promotions
|
|
986
|
+
|
|
987
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
988
|
+
|---|---|---|---|---|
|
|
989
|
+
| approve | POST | `/devops/v1/promotions/{id}:approve` | no | no |
|
|
990
|
+
| cancel | POST | `/devops/v1/promotions/{id}:cancel` | no | no |
|
|
991
|
+
| conclude | POST | `/devops/v1/promotions/{id}:conclude` | no | no |
|
|
992
|
+
| create | POST | `/devops/v1/promotions` | no | no |
|
|
993
|
+
| retrieve | GET | `/devops/v1/promotions/{id}` | no | no |
|
|
994
|
+
| retry | POST | `/devops/v1/promotions/{id}:retry` | no | no |
|
|
995
|
+
|
|
996
|
+
### devops.promotions.rollouts
|
|
997
|
+
|
|
998
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
999
|
+
|---|---|---|---|---|
|
|
1000
|
+
| list | GET | `/devops/v1/promotions/{promotion}/rollouts` | no | no |
|
|
1001
|
+
|
|
1002
|
+
### devops.releases
|
|
1003
|
+
|
|
1004
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1005
|
+
|---|---|---|---|---|
|
|
1006
|
+
| abandon | POST | `/devops/v1/releases/{id}:abandon` | no | no |
|
|
1007
|
+
| retrieve | GET | `/devops/v1/releases/{id}` | no | no |
|
|
1008
|
+
|
|
1009
|
+
### devops.rollouts
|
|
1010
|
+
|
|
1011
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1012
|
+
|---|---|---|---|---|
|
|
1013
|
+
| retrieve | GET | `/devops/v1/rollouts/{id}` | no | no |
|
|
1014
|
+
|
|
919
1015
|
### devops.testCases
|
|
920
1016
|
|
|
921
1017
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1068,12 +1164,25 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1068
1164
|
|
|
1069
1165
|
## media
|
|
1070
1166
|
|
|
1167
|
+
### media.assets
|
|
1168
|
+
|
|
1169
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1170
|
+
|---|---|---|---|---|
|
|
1171
|
+
| edit | POST | `/media/v1/libraries/{library_id}/assets/{asset_id}/edits` | no | no |
|
|
1172
|
+
| lineage | GET | `/media/v1/libraries/{library_id}/assets/{asset_id}/lineage` | no | no |
|
|
1173
|
+
|
|
1071
1174
|
### media.generation.capabilities
|
|
1072
1175
|
|
|
1073
1176
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
1074
1177
|
|---|---|---|---|---|
|
|
1075
1178
|
| list | GET | `/media/v1/generation/capabilities` | no | no |
|
|
1076
1179
|
|
|
1180
|
+
### media.images
|
|
1181
|
+
|
|
1182
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1183
|
+
|---|---|---|---|---|
|
|
1184
|
+
| generate | POST | `/media/v1/libraries/{library_id}/images/generations` | no | no |
|
|
1185
|
+
|
|
1077
1186
|
### media.libraries
|
|
1078
1187
|
|
|
1079
1188
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1083,6 +1192,8 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1083
1192
|
| list | GET | `/media/v1/libraries` | no | yes |
|
|
1084
1193
|
| restore | POST | `/media/v1/libraries/{library_id}/restore` | no | no |
|
|
1085
1194
|
| retrieve | GET | `/media/v1/libraries/{library_id}` | no | no |
|
|
1195
|
+
| retrieveDefault | GET | `/media/v1/libraries/default` | no | no |
|
|
1196
|
+
| setDefault | PUT | `/media/v1/libraries/default` | no | no |
|
|
1086
1197
|
| update | PATCH | `/media/v1/libraries/{library_id}` | no | no |
|
|
1087
1198
|
|
|
1088
1199
|
### media.libraries.assets
|
|
@@ -1145,12 +1256,6 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1145
1256
|
|---|---|---|---|---|
|
|
1146
1257
|
| list | GET | `/media/v1/libraries/{library_id}/folders` | no | no |
|
|
1147
1258
|
|
|
1148
|
-
### media.libraries.generations
|
|
1149
|
-
|
|
1150
|
-
| Method | HTTP | Path | Streaming | Pagination |
|
|
1151
|
-
|---|---|---|---|---|
|
|
1152
|
-
| create | POST | `/media/v1/libraries/{library_id}/generations` | no | no |
|
|
1153
|
-
|
|
1154
1259
|
### media.libraries.jobs
|
|
1155
1260
|
|
|
1156
1261
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1159,12 +1264,6 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1159
1264
|
| list | GET | `/media/v1/libraries/{library_id}/jobs` | no | yes |
|
|
1160
1265
|
| retrieve | GET | `/media/v1/libraries/{library_id}/jobs/{job_id}` | no | no |
|
|
1161
1266
|
|
|
1162
|
-
### media.libraries.jobs.outputs.save
|
|
1163
|
-
|
|
1164
|
-
| Method | HTTP | Path | Streaming | Pagination |
|
|
1165
|
-
|---|---|---|---|---|
|
|
1166
|
-
| create | POST | `/media/v1/libraries/{library_id}/jobs/{job_id}/outputs/{index}/save` | no | no |
|
|
1167
|
-
|
|
1168
1267
|
### media.libraries.purge
|
|
1169
1268
|
|
|
1170
1269
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1202,6 +1301,18 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1202
1301
|
| list | GET | `/media/v1/libraries/{library_id}/understandings` | no | yes |
|
|
1203
1302
|
| retrieveFailureSummary | GET | `/media/v1/libraries/{library_id}/understandings/failure_summary` | no | no |
|
|
1204
1303
|
|
|
1304
|
+
### media.speech
|
|
1305
|
+
|
|
1306
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1307
|
+
|---|---|---|---|---|
|
|
1308
|
+
| create | POST | `/media/v1/libraries/{library_id}/audio/speech` | no | no |
|
|
1309
|
+
|
|
1310
|
+
### media.videos
|
|
1311
|
+
|
|
1312
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1313
|
+
|---|---|---|---|---|
|
|
1314
|
+
| generate | POST | `/media/v1/libraries/{library_id}/videos/generations` | no | no |
|
|
1315
|
+
|
|
1205
1316
|
## meta
|
|
1206
1317
|
|
|
1207
1318
|
### meta.docs
|
|
@@ -1366,6 +1477,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1366
1477
|
| create | POST | `/ontology/v1/nodes` | no | no |
|
|
1367
1478
|
| list | GET | `/ontology/v1/nodes` | no | yes |
|
|
1368
1479
|
| retrieve | GET | `/ontology/v1/nodes/{node_id}` | no | no |
|
|
1480
|
+
| retrieveNeighborhood | GET | `/ontology/v1/nodes/{node_id}/neighborhood` | no | no |
|
|
1369
1481
|
| update | PATCH | `/ontology/v1/nodes/{node_id}` | no | no |
|
|
1370
1482
|
|
|
1371
1483
|
### ontology.nodes.merge
|
|
@@ -1634,6 +1746,13 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1634
1746
|
| list | GET | `/studio/v1/platforms` | no | no |
|
|
1635
1747
|
| retrieve | GET | `/studio/v1/platforms/{platform}` | no | no |
|
|
1636
1748
|
|
|
1749
|
+
### studio.reviewers
|
|
1750
|
+
|
|
1751
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1752
|
+
|---|---|---|---|---|
|
|
1753
|
+
| list | GET | `/studio/v1/reviewers` | no | no |
|
|
1754
|
+
| update | PATCH | `/studio/v1/reviewers/{agent}` | no | no |
|
|
1755
|
+
|
|
1637
1756
|
### studio.styles
|
|
1638
1757
|
|
|
1639
1758
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1687,6 +1806,12 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1687
1806
|
| retrieveReview | GET | `/studio/v1/works/{work}/drafts/{draft}/review` | no | no |
|
|
1688
1807
|
| update | PATCH | `/studio/v1/works/{work}/drafts/{draft}` | no | no |
|
|
1689
1808
|
|
|
1809
|
+
### studio.works.drafts.renditions
|
|
1810
|
+
|
|
1811
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1812
|
+
|---|---|---|---|---|
|
|
1813
|
+
| create | POST | `/studio/v1/works/{work}/drafts/{draft}/renditions` | no | no |
|
|
1814
|
+
|
|
1690
1815
|
### studio.works.drafts.status
|
|
1691
1816
|
|
|
1692
1817
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1701,6 +1826,35 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1701
1826
|
| batchUpdate | POST | `/studio/v1/works/{work}/drafts/{draft}/units:batchUpdate` | no | no |
|
|
1702
1827
|
| create | POST | `/studio/v1/works/{work}/drafts/{draft}/units` | no | no |
|
|
1703
1828
|
|
|
1829
|
+
### studio.works.renditions
|
|
1830
|
+
|
|
1831
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1832
|
+
|---|---|---|---|---|
|
|
1833
|
+
| delete | DELETE | `/studio/v1/works/{work}/renditions/{rendition}` | no | no |
|
|
1834
|
+
| list | GET | `/studio/v1/works/{work}/renditions` | no | no |
|
|
1835
|
+
| publish | POST | `/studio/v1/works/{work}/renditions/{rendition}:publish` | no | no |
|
|
1836
|
+
| render | POST | `/studio/v1/works/{work}/renditions/{rendition}:render` | no | no |
|
|
1837
|
+
| retrieve | GET | `/studio/v1/works/{work}/renditions/{rendition}` | no | no |
|
|
1838
|
+
| retrieveContent | GET | `/studio/v1/works/{work}/renditions/{rendition}/content` | no | no |
|
|
1839
|
+
| update | PATCH | `/studio/v1/works/{work}/renditions/{rendition}` | no | no |
|
|
1840
|
+
|
|
1841
|
+
### studio.works.reviewSettings
|
|
1842
|
+
|
|
1843
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1844
|
+
|---|---|---|---|---|
|
|
1845
|
+
| retrieve | GET | `/studio/v1/works/{work}/review-settings` | no | no |
|
|
1846
|
+
| update | PATCH | `/studio/v1/works/{work}/review-settings` | no | no |
|
|
1847
|
+
|
|
1848
|
+
### studio.works.reviews
|
|
1849
|
+
|
|
1850
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1851
|
+
|---|---|---|---|---|
|
|
1852
|
+
| appeal | POST | `/studio/v1/works/{work}/reviews/{review}:appeal` | no | no |
|
|
1853
|
+
| cancel | POST | `/studio/v1/works/{work}/reviews/{review}:cancel` | no | no |
|
|
1854
|
+
| create | POST | `/studio/v1/works/{work}/reviews` | no | no |
|
|
1855
|
+
| list | GET | `/studio/v1/works/{work}/reviews` | no | no |
|
|
1856
|
+
| retrieve | GET | `/studio/v1/works/{work}/reviews/{review}` | no | no |
|
|
1857
|
+
|
|
1704
1858
|
### studio.works.units
|
|
1705
1859
|
|
|
1706
1860
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -1955,11 +2109,19 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1955
2109
|
| crm.properties.archive | CRM DELETE archives the resource rather than permanently deleting it; expose the archive product verb. |
|
|
1956
2110
|
| database.databases.rest.create | The final parameter identifies a table collection; POST inserts rows rather than updating the table. |
|
|
1957
2111
|
| file.uploads.createSigned | Signed upload creation returns a one-time local PUT URL; ADR-039 names this operation uploads.createSigned. |
|
|
2112
|
+
| media.libraries.retrieveDefault | ADR-094 §9 names the default-library read libraries.retrieveDefault; the URL names a reference rather than an id, so the path-derived name would otherwise read as retrieving a library called default. |
|
|
2113
|
+
| media.libraries.setDefault | ADR-094 §9 names the default-library write libraries.setDefault; the URL has no library id because the organization owns one default library, so the path alone cannot say which. |
|
|
2114
|
+
| media.assets.edit | ADR-094 §9 names the edit write assets.edit; an edit acts on the addressed asset and returns a Job, so the URL nesting under a library is a mount rather than an SDK resource level. |
|
|
2115
|
+
| media.assets.lineage | ADR-094 §9 names the edit-tree read assets.lineage; lineage is the product verb and the URL nesting under a library is a mount, not an SDK resource level. |
|
|
2116
|
+
| media.speech.create | ADR-094 §1/§9 names speech synthesis speech.create; the URL says audio/speech because that is the artifact the caller gets back, and the path alone would derive a speech collection create under an audio level that is not an SDK resource. |
|
|
2117
|
+
| media.images.generate | ADR-094 §9 names image generation images.generate; the URL mounts it under a library, but generation is an operation on images and the path alone would derive a generations collection create. |
|
|
2118
|
+
| media.videos.generate | ADR-094 §2/§9 names video generation videos.generate beside images.generate; the URL mounts it under a library, but generation is an operation on videos and the path alone would derive a generations collection create. The unqualified videos resource is the video lane, distinct from the batch and legacy job resources. |
|
|
1958
2119
|
| meta.docs.search | Documentation keyword search is an operation on docs, not a nested collection. |
|
|
1959
2120
|
| sandbox.sandboxes.commands.run | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
1960
2121
|
| sandbox.sandboxes.files.remove | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
1961
2122
|
| sandbox.sandboxes.files.read | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
1962
2123
|
| sandbox.sandboxes.files.write | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
2124
|
+
| studio.works.reviewSettings.retrieve | A work has one review-settings singleton; the segment ends in s only because English writes it that way, so the collection rule would derive reviewSettings.list for a read that returns the settings object itself. |
|
|
1963
2125
|
| vault.oauth.retrieveClientMetadata | The literal .json filename otherwise introduces a dot inside a method identifier. |
|
|
1964
2126
|
|
|
1965
2127
|
## SDK parameter aliases
|
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ conversation with it, on its own machine.
|
|
|
122
122
|
```ts
|
|
123
123
|
const { sandboxes } = praxis.sandbox;
|
|
124
124
|
const sandbox = await sandboxes.create({
|
|
125
|
-
body: { templateID: 'base' },
|
|
125
|
+
body: { templateID: 'base', autoPause: false }, // ends at its timeout; autoPause: true keeps a long-lived computer
|
|
126
126
|
});
|
|
127
127
|
const result = await sandboxes.commands.run({
|
|
128
128
|
path: { sandbox_id: sandbox.sandboxID },
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Default credential chain for code running on a Praxis computer (ticket-5367):
|
|
3
|
-
* PRAXIS_API_TOKEN environment variable, then
|
|
4
|
-
*
|
|
2
|
+
* Default credential chain for code running on a Praxis computer (ticket-5367, ADR-098 §2):
|
|
3
|
+
* the PRAXIS_API_TOKEN environment variable, then the login file of the environment,
|
|
4
|
+
* `~/.praxis/cli/<env>.json` — the one file `praxis login` writes for a person and the platform writes
|
|
5
|
+
* for a managed login. Resolved at call time so a token the platform renewed in the file is picked up
|
|
6
|
+
* by an already-running process.
|
|
5
7
|
*/
|
|
6
8
|
export interface ResolvedCredentials {
|
|
7
9
|
token?: string;
|
|
@@ -9,6 +11,13 @@ export interface ResolvedCredentials {
|
|
|
9
11
|
}
|
|
10
12
|
type Env = Record<string, string | undefined>;
|
|
11
13
|
type ReadFile = (path: string) => string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Which environment's login file applies: PRAXIS_ENV when it names one, otherwise a `-develop.` host in
|
|
16
|
+
* PRAXIS_API_URL means develop and any other host production — the rule apps/cli/src/config/env.ts
|
|
17
|
+
* applies. A PRAXIS_ENV that is not a plain name is no environment at all and is ignored. Pure.
|
|
18
|
+
*/
|
|
19
|
+
export declare function credentialsEnv(env: Env): string;
|
|
20
|
+
/** The one login file, the same path the CLI reads for this environment. Null without a home directory. Pure. */
|
|
12
21
|
export declare function credentialsPath(env: Env): string | null;
|
|
13
22
|
export declare function resolveDefaultCredentials(env?: Env, readFile?: ReadFile): ResolvedCredentials;
|
|
14
23
|
export {};
|
package/dist/core/credentials.js
CHANGED
|
@@ -8,9 +8,29 @@ function defaultReadFile(path) {
|
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Which environment's login file applies: PRAXIS_ENV when it names one, otherwise a `-develop.` host in
|
|
13
|
+
* PRAXIS_API_URL means develop and any other host production — the rule apps/cli/src/config/env.ts
|
|
14
|
+
* applies. A PRAXIS_ENV that is not a plain name is no environment at all and is ignored. Pure.
|
|
15
|
+
*/
|
|
16
|
+
export function credentialsEnv(env) {
|
|
17
|
+
const declared = nonEmpty(env.PRAXIS_ENV);
|
|
18
|
+
if (declared && /^[A-Za-z0-9_-]+$/.test(declared))
|
|
19
|
+
return declared;
|
|
20
|
+
const apiUrl = nonEmpty(env.PRAXIS_API_URL);
|
|
21
|
+
if (apiUrl) {
|
|
22
|
+
try {
|
|
23
|
+
if (new URL(apiUrl).hostname.includes('-develop.'))
|
|
24
|
+
return 'develop';
|
|
25
|
+
}
|
|
26
|
+
catch { /* a malformed URL is not evidence of develop */ }
|
|
27
|
+
}
|
|
28
|
+
return 'production';
|
|
29
|
+
}
|
|
30
|
+
/** The one login file, the same path the CLI reads for this environment. Null without a home directory. Pure. */
|
|
11
31
|
export function credentialsPath(env) {
|
|
12
32
|
const home = nonEmpty(env.HOME) ?? nonEmpty(env.USERPROFILE);
|
|
13
|
-
return home ? `${home.replace(
|
|
33
|
+
return home ? `${home.replace(/[/\\]+$/, '')}/.praxis/cli/${credentialsEnv(env)}.json` : null;
|
|
14
34
|
}
|
|
15
35
|
export function resolveDefaultCredentials(env = globalThis.process?.env ?? {}, readFile = defaultReadFile) {
|
|
16
36
|
const envToken = nonEmpty(env.PRAXIS_API_TOKEN);
|
|
@@ -23,7 +43,7 @@ export function resolveDefaultCredentials(env = globalThis.process?.env ?? {}, r
|
|
|
23
43
|
return envUrl ? { apiUrl: envUrl } : {};
|
|
24
44
|
try {
|
|
25
45
|
const file = JSON.parse(text);
|
|
26
|
-
const token = nonEmpty(file.
|
|
46
|
+
const token = nonEmpty(file.access_token);
|
|
27
47
|
const apiUrl = envUrl ?? nonEmpty(file.api_url);
|
|
28
48
|
return { ...(token ? { token } : {}), ...(apiUrl ? { apiUrl } : {}) };
|
|
29
49
|
}
|
package/dist/core/transport.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SSEEvent } from './sse.js';
|
|
2
2
|
export interface PraxisOptions {
|
|
3
|
-
/** Explicit key. Omitted on a Praxis computer: PRAXIS_API_TOKEN, then
|
|
3
|
+
/** Explicit key. Omitted on a Praxis computer: PRAXIS_API_TOKEN, then the login file `~/.praxis/cli/<env>.json`, are used. */
|
|
4
4
|
apiKey?: string;
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
timeoutMs?: number;
|