@foxnose/sdk 0.1.1 → 0.2.1
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/README.md +24 -0
- package/dist/index.cjs +71 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -9
- package/dist/index.d.ts +20 -9
- package/dist/index.js +71 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Official TypeScript SDK for the [FoxNose](https://foxnose.net/?utm_source=github
|
|
|
12
12
|
- **Async-only API** built on native `fetch` (Node 18+)
|
|
13
13
|
- **Automatic retries** with exponential backoff and Retry-After support
|
|
14
14
|
- **Four auth strategies** — Anonymous, JWT, Simple key, and Secure (ECDSA P-256)
|
|
15
|
+
- **Flux introspection** — discover route contracts with `/_router` and `/_schema`
|
|
15
16
|
- **Zero dependencies** — uses only Node.js built-in modules
|
|
16
17
|
- **Dual output** — ESM and CommonJS builds with full `.d.ts` declarations
|
|
17
18
|
|
|
@@ -87,9 +88,32 @@ const results = await client.search('articles', {
|
|
|
87
88
|
size: 10,
|
|
88
89
|
});
|
|
89
90
|
|
|
91
|
+
// Discover available routes for this API prefix
|
|
92
|
+
const router = await client.getRouter();
|
|
93
|
+
console.log(router.routes.length);
|
|
94
|
+
|
|
95
|
+
// Get live schema metadata for a folder route
|
|
96
|
+
const schema = await client.getSchema('articles');
|
|
97
|
+
console.log(schema.searchable_fields);
|
|
98
|
+
|
|
90
99
|
client.close();
|
|
91
100
|
```
|
|
92
101
|
|
|
102
|
+
### API Folder Route Descriptions
|
|
103
|
+
|
|
104
|
+
You can configure per-route descriptions when connecting a folder to an API.
|
|
105
|
+
These descriptions are returned by Flux `/_router` introspection.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
await managementClient.addApiFolder(api.key, folder.key, {
|
|
109
|
+
allowedMethods: ['get_many', 'get_one'],
|
|
110
|
+
descriptionGetOne: 'Get one article by key',
|
|
111
|
+
descriptionGetMany: 'List published articles',
|
|
112
|
+
descriptionSearch: 'Search published articles',
|
|
113
|
+
descriptionSchema: 'Read article schema',
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
93
117
|
## Authentication
|
|
94
118
|
|
|
95
119
|
The SDK supports four authentication strategies:
|
package/dist/index.cjs
CHANGED
|
@@ -193,7 +193,7 @@ var DEFAULT_RETRY_CONFIG = {
|
|
|
193
193
|
statusCodes: [408, 425, 429, 500, 502, 503, 504],
|
|
194
194
|
methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
|
|
195
195
|
};
|
|
196
|
-
var SDK_VERSION = "0.
|
|
196
|
+
var SDK_VERSION = "0.2.1";
|
|
197
197
|
var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
|
|
198
198
|
function createConfig(options) {
|
|
199
199
|
if (!options.baseUrl) {
|
|
@@ -409,9 +409,7 @@ function resolveKey(value) {
|
|
|
409
409
|
if (value && typeof value === "object" && "key" in value && typeof value.key === "string") {
|
|
410
410
|
return value.key;
|
|
411
411
|
}
|
|
412
|
-
throw new TypeError(
|
|
413
|
-
`Expected a string or an object with a 'key' attribute, got ${typeof value}`
|
|
414
|
-
);
|
|
412
|
+
throw new TypeError(`Expected a string or an object with a 'key' attribute, got ${typeof value}`);
|
|
415
413
|
}
|
|
416
414
|
|
|
417
415
|
// src/management/paths.ts
|
|
@@ -609,9 +607,21 @@ var ManagementClient = class {
|
|
|
609
607
|
const aKey = resolveKey(apiKey);
|
|
610
608
|
const fKey = resolveKey(folderKey);
|
|
611
609
|
const body = { folder: fKey };
|
|
612
|
-
if (options?.allowedMethods) {
|
|
610
|
+
if (options?.allowedMethods !== void 0) {
|
|
613
611
|
body.allowed_methods = options.allowedMethods;
|
|
614
612
|
}
|
|
613
|
+
if (options?.descriptionGetOne !== void 0) {
|
|
614
|
+
body.description_get_one = options.descriptionGetOne;
|
|
615
|
+
}
|
|
616
|
+
if (options?.descriptionGetMany !== void 0) {
|
|
617
|
+
body.description_get_many = options.descriptionGetMany;
|
|
618
|
+
}
|
|
619
|
+
if (options?.descriptionSearch !== void 0) {
|
|
620
|
+
body.description_search = options.descriptionSearch;
|
|
621
|
+
}
|
|
622
|
+
if (options?.descriptionSchema !== void 0) {
|
|
623
|
+
body.description_schema = options.descriptionSchema;
|
|
624
|
+
}
|
|
615
625
|
return this.request("POST", `${this.paths.apiFoldersRoot(aKey)}/`, { jsonBody: body });
|
|
616
626
|
}
|
|
617
627
|
async getApiFolder(apiKey, folderKey) {
|
|
@@ -623,9 +633,21 @@ var ManagementClient = class {
|
|
|
623
633
|
const aKey = resolveKey(apiKey);
|
|
624
634
|
const fKey = resolveKey(folderKey);
|
|
625
635
|
const body = {};
|
|
626
|
-
if (options?.allowedMethods) {
|
|
636
|
+
if (options?.allowedMethods !== void 0) {
|
|
627
637
|
body.allowed_methods = options.allowedMethods;
|
|
628
638
|
}
|
|
639
|
+
if (options?.descriptionGetOne !== void 0) {
|
|
640
|
+
body.description_get_one = options.descriptionGetOne;
|
|
641
|
+
}
|
|
642
|
+
if (options?.descriptionGetMany !== void 0) {
|
|
643
|
+
body.description_get_many = options.descriptionGetMany;
|
|
644
|
+
}
|
|
645
|
+
if (options?.descriptionSearch !== void 0) {
|
|
646
|
+
body.description_search = options.descriptionSearch;
|
|
647
|
+
}
|
|
648
|
+
if (options?.descriptionSchema !== void 0) {
|
|
649
|
+
body.description_schema = options.descriptionSchema;
|
|
650
|
+
}
|
|
629
651
|
return this.request("PUT", `${this.paths.apiFoldersRoot(aKey)}/${fKey}/`, {
|
|
630
652
|
jsonBody: body
|
|
631
653
|
});
|
|
@@ -746,11 +768,10 @@ var ManagementClient = class {
|
|
|
746
768
|
}
|
|
747
769
|
async deleteFluxRolePermission(roleKey, contentType) {
|
|
748
770
|
const key = resolveKey(roleKey);
|
|
749
|
-
await this.request(
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
);
|
|
771
|
+
await this.request("DELETE", `${this.paths.fluxRolePermissionsRoot(key)}/`, {
|
|
772
|
+
params: { content_type: contentType },
|
|
773
|
+
parseJson: false
|
|
774
|
+
});
|
|
754
775
|
}
|
|
755
776
|
async replaceFluxRolePermissions(roleKey, permissions) {
|
|
756
777
|
const key = resolveKey(roleKey);
|
|
@@ -866,10 +887,7 @@ var ManagementClient = class {
|
|
|
866
887
|
async publishFolderVersion(folderKey, versionKey) {
|
|
867
888
|
const fKey = resolveKey(folderKey);
|
|
868
889
|
const vKey = resolveKey(versionKey);
|
|
869
|
-
return this.request(
|
|
870
|
-
"POST",
|
|
871
|
-
`${this.paths.folderVersionsBase(fKey)}/${vKey}/publish/`
|
|
872
|
-
);
|
|
890
|
+
return this.request("POST", `${this.paths.folderVersionsBase(fKey)}/${vKey}/publish/`);
|
|
873
891
|
}
|
|
874
892
|
// ------------------------------------------------------------------ //
|
|
875
893
|
// Folder field operations
|
|
@@ -889,29 +907,25 @@ var ManagementClient = class {
|
|
|
889
907
|
async getFolderField(folderKey, versionKey, fieldPath) {
|
|
890
908
|
const fKey = resolveKey(folderKey);
|
|
891
909
|
const vKey = resolveKey(versionKey);
|
|
892
|
-
return this.request(
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
{ params: { path: fieldPath } }
|
|
896
|
-
);
|
|
910
|
+
return this.request("GET", `${this.paths.folderSchemaTree(fKey, vKey)}/field/`, {
|
|
911
|
+
params: { path: fieldPath }
|
|
912
|
+
});
|
|
897
913
|
}
|
|
898
914
|
async updateFolderField(folderKey, versionKey, fieldPath, payload) {
|
|
899
915
|
const fKey = resolveKey(folderKey);
|
|
900
916
|
const vKey = resolveKey(versionKey);
|
|
901
|
-
return this.request(
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
);
|
|
917
|
+
return this.request("PUT", `${this.paths.folderSchemaTree(fKey, vKey)}/field/`, {
|
|
918
|
+
params: { path: fieldPath },
|
|
919
|
+
jsonBody: payload
|
|
920
|
+
});
|
|
906
921
|
}
|
|
907
922
|
async deleteFolderField(folderKey, versionKey, fieldPath) {
|
|
908
923
|
const fKey = resolveKey(folderKey);
|
|
909
924
|
const vKey = resolveKey(versionKey);
|
|
910
|
-
await this.request(
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
);
|
|
925
|
+
await this.request("DELETE", `${this.paths.folderSchemaTree(fKey, vKey)}/field/`, {
|
|
926
|
+
params: { path: fieldPath },
|
|
927
|
+
parseJson: false
|
|
928
|
+
});
|
|
915
929
|
}
|
|
916
930
|
// ------------------------------------------------------------------ //
|
|
917
931
|
// Component operations
|
|
@@ -966,10 +980,7 @@ var ManagementClient = class {
|
|
|
966
980
|
async publishComponentVersion(componentKey, versionKey) {
|
|
967
981
|
const cKey = resolveKey(componentKey);
|
|
968
982
|
const vKey = resolveKey(versionKey);
|
|
969
|
-
return this.request(
|
|
970
|
-
"POST",
|
|
971
|
-
`${this.paths.componentVersionsBase(cKey)}/${vKey}/publish/`
|
|
972
|
-
);
|
|
983
|
+
return this.request("POST", `${this.paths.componentVersionsBase(cKey)}/${vKey}/publish/`);
|
|
973
984
|
}
|
|
974
985
|
async updateComponentVersion(componentKey, versionKey, payload) {
|
|
975
986
|
const cKey = resolveKey(componentKey);
|
|
@@ -1003,29 +1014,25 @@ var ManagementClient = class {
|
|
|
1003
1014
|
async getComponentField(componentKey, versionKey, fieldPath) {
|
|
1004
1015
|
const cKey = resolveKey(componentKey);
|
|
1005
1016
|
const vKey = resolveKey(versionKey);
|
|
1006
|
-
return this.request(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
{ params: { path: fieldPath } }
|
|
1010
|
-
);
|
|
1017
|
+
return this.request("GET", `${this.paths.componentSchemaTree(cKey, vKey)}/field/`, {
|
|
1018
|
+
params: { path: fieldPath }
|
|
1019
|
+
});
|
|
1011
1020
|
}
|
|
1012
1021
|
async updateComponentField(componentKey, versionKey, fieldPath, payload) {
|
|
1013
1022
|
const cKey = resolveKey(componentKey);
|
|
1014
1023
|
const vKey = resolveKey(versionKey);
|
|
1015
|
-
return this.request(
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
);
|
|
1024
|
+
return this.request("PUT", `${this.paths.componentSchemaTree(cKey, vKey)}/field/`, {
|
|
1025
|
+
params: { path: fieldPath },
|
|
1026
|
+
jsonBody: payload
|
|
1027
|
+
});
|
|
1020
1028
|
}
|
|
1021
1029
|
async deleteComponentField(componentKey, versionKey, fieldPath) {
|
|
1022
1030
|
const cKey = resolveKey(componentKey);
|
|
1023
1031
|
const vKey = resolveKey(versionKey);
|
|
1024
|
-
await this.request(
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
);
|
|
1032
|
+
await this.request("DELETE", `${this.paths.componentSchemaTree(cKey, vKey)}/field/`, {
|
|
1033
|
+
params: { path: fieldPath },
|
|
1034
|
+
parseJson: false
|
|
1035
|
+
});
|
|
1029
1036
|
}
|
|
1030
1037
|
// ------------------------------------------------------------------ //
|
|
1031
1038
|
// Resource operations
|
|
@@ -1190,10 +1197,7 @@ var ManagementClient = class {
|
|
|
1190
1197
|
const fKey = resolveKey(folderKey);
|
|
1191
1198
|
const rKey = resolveKey(resourceKey);
|
|
1192
1199
|
const rvKey = resolveKey(revisionKey);
|
|
1193
|
-
return this.request(
|
|
1194
|
-
"POST",
|
|
1195
|
-
`${this.paths.revisionBase(fKey, rKey)}/${rvKey}/validate/`
|
|
1196
|
-
);
|
|
1200
|
+
return this.request("POST", `${this.paths.revisionBase(fKey, rKey)}/${rvKey}/validate/`);
|
|
1197
1201
|
}
|
|
1198
1202
|
async getRevisionData(folderKey, resourceKey, revisionKey) {
|
|
1199
1203
|
const fKey = resolveKey(folderKey);
|
|
@@ -1298,11 +1302,9 @@ var ManagementClient = class {
|
|
|
1298
1302
|
const oKey = resolveKey(orgKey);
|
|
1299
1303
|
const pKey = resolveKey(projectKey);
|
|
1300
1304
|
const eKey = resolveKey(envKey);
|
|
1301
|
-
await this.request(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
{ jsonBody: { is_enabled: isEnabled } }
|
|
1305
|
-
);
|
|
1305
|
+
await this.request("POST", `${this.paths.environmentRoot(oKey, pKey, eKey)}/toggle/`, {
|
|
1306
|
+
jsonBody: { is_enabled: isEnabled }
|
|
1307
|
+
});
|
|
1306
1308
|
}
|
|
1307
1309
|
async updateEnvironmentProtection(orgKey, projectKey, envKey, options) {
|
|
1308
1310
|
const oKey = resolveKey(orgKey);
|
|
@@ -1312,11 +1314,9 @@ var ManagementClient = class {
|
|
|
1312
1314
|
if (options.protectionReason) {
|
|
1313
1315
|
body.protection_reason = options.protectionReason;
|
|
1314
1316
|
}
|
|
1315
|
-
return this.request(
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
{ jsonBody: body }
|
|
1319
|
-
);
|
|
1317
|
+
return this.request("PATCH", `${this.paths.environmentRoot(oKey, pKey, eKey)}/protection/`, {
|
|
1318
|
+
jsonBody: body
|
|
1319
|
+
});
|
|
1320
1320
|
}
|
|
1321
1321
|
async clearEnvironmentProtection(orgKey, projectKey, envKey) {
|
|
1322
1322
|
return this.updateEnvironmentProtection(orgKey, projectKey, envKey, {
|
|
@@ -1369,6 +1369,14 @@ var FluxClient = class {
|
|
|
1369
1369
|
const path = this.buildPath(folderPath, "/_search");
|
|
1370
1370
|
return this.transport.request("POST", path, { jsonBody: body });
|
|
1371
1371
|
}
|
|
1372
|
+
async getRouter() {
|
|
1373
|
+
const path = `/${this.apiPrefix}/_router`;
|
|
1374
|
+
return this.transport.request("GET", path);
|
|
1375
|
+
}
|
|
1376
|
+
async getSchema(folderPath) {
|
|
1377
|
+
const path = this.buildPath(folderPath, "/_schema");
|
|
1378
|
+
return this.transport.request("GET", path);
|
|
1379
|
+
}
|
|
1372
1380
|
close() {
|
|
1373
1381
|
this.transport.close();
|
|
1374
1382
|
}
|