@zilfu/sdk 0.1.0 → 0.1.2
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/LICENSE +21 -0
- package/README.md +113 -21
- package/dist/index.cjs +84 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -106
- package/dist/index.d.ts +61 -106
- package/dist/index.js +84 -33
- package/dist/index.js.map +1 -1
- package/package.json +14 -17
- package/openapi.json +0 -3541
- package/src/client.ts +0 -41
- package/src/generated/client/client.gen.ts +0 -280
- package/src/generated/client/index.ts +0 -25
- package/src/generated/client/types.gen.ts +0 -217
- package/src/generated/client/utils.gen.ts +0 -318
- package/src/generated/client.gen.ts +0 -16
- package/src/generated/core/auth.gen.ts +0 -41
- package/src/generated/core/bodySerializer.gen.ts +0 -82
- package/src/generated/core/params.gen.ts +0 -169
- package/src/generated/core/pathSerializer.gen.ts +0 -171
- package/src/generated/core/queryKeySerializer.gen.ts +0 -117
- package/src/generated/core/serverSentEvents.gen.ts +0 -242
- package/src/generated/core/types.gen.ts +0 -104
- package/src/generated/core/utils.gen.ts +0 -140
- package/src/generated/index.ts +0 -4
- package/src/generated/sdk.gen.ts +0 -658
- package/src/generated/types.gen.ts +0 -2564
- package/src/index.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -821,7 +821,7 @@ var HeyApiRegistry = class {
|
|
|
821
821
|
get(key) {
|
|
822
822
|
const instance = this.instances.get(key ?? this.defaultKey);
|
|
823
823
|
if (!instance) {
|
|
824
|
-
throw new Error(`No SDK client found. Create one with "new
|
|
824
|
+
throw new Error(`No SDK client found. Create one with "new ZilfuApi()" to fix this error.`);
|
|
825
825
|
}
|
|
826
826
|
return instance;
|
|
827
827
|
}
|
|
@@ -830,18 +830,6 @@ var HeyApiRegistry = class {
|
|
|
830
830
|
}
|
|
831
831
|
};
|
|
832
832
|
var Accounts = class extends HeyApiClient {
|
|
833
|
-
/**
|
|
834
|
-
* Disconnect multiple accounts
|
|
835
|
-
*
|
|
836
|
-
* Removes several social account connections in a single request and dispatches a webhook event for each.
|
|
837
|
-
*/
|
|
838
|
-
deleteMany(options) {
|
|
839
|
-
return (options.client ?? this.client).delete({
|
|
840
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
841
|
-
url: "/spaces/{space}/accounts",
|
|
842
|
-
...options
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
833
|
/**
|
|
846
834
|
* List accounts
|
|
847
835
|
*
|
|
@@ -881,7 +869,7 @@ var Accounts = class extends HeyApiClient {
|
|
|
881
869
|
/**
|
|
882
870
|
* Disconnect an account
|
|
883
871
|
*
|
|
884
|
-
* Removes the
|
|
872
|
+
* Removes the given account and every other account on the same platform within the space, dispatching an AccountDisconnected webhook for each.
|
|
885
873
|
*/
|
|
886
874
|
delete(options) {
|
|
887
875
|
return (options.client ?? this.client).delete({
|
|
@@ -891,7 +879,7 @@ var Accounts = class extends HeyApiClient {
|
|
|
891
879
|
});
|
|
892
880
|
}
|
|
893
881
|
};
|
|
894
|
-
var
|
|
882
|
+
var ApiTokens = class extends HeyApiClient {
|
|
895
883
|
/**
|
|
896
884
|
* Create an API token
|
|
897
885
|
*
|
|
@@ -921,7 +909,7 @@ var Tokens = class extends HeyApiClient {
|
|
|
921
909
|
});
|
|
922
910
|
}
|
|
923
911
|
};
|
|
924
|
-
var
|
|
912
|
+
var Blocks = class extends HeyApiClient {
|
|
925
913
|
list(options) {
|
|
926
914
|
return (options.client ?? this.client).get({
|
|
927
915
|
security: [{ scheme: "bearer", type: "http" }],
|
|
@@ -1012,6 +1000,19 @@ var Bio = class extends HeyApiClient {
|
|
|
1012
1000
|
}
|
|
1013
1001
|
});
|
|
1014
1002
|
}
|
|
1003
|
+
_blocks;
|
|
1004
|
+
get blocks() {
|
|
1005
|
+
return this._blocks ??= new Blocks({ client: this.client });
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
var Health = class extends HeyApiClient {
|
|
1009
|
+
check(options) {
|
|
1010
|
+
return (options?.client ?? this.client).get({
|
|
1011
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1012
|
+
url: "/health",
|
|
1013
|
+
...options
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1015
1016
|
};
|
|
1016
1017
|
var Media = class extends HeyApiClient {
|
|
1017
1018
|
/**
|
|
@@ -1330,28 +1331,28 @@ var Webhooks = class extends HeyApiClient {
|
|
|
1330
1331
|
});
|
|
1331
1332
|
}
|
|
1332
1333
|
};
|
|
1333
|
-
var
|
|
1334
|
+
var ZilfuApi = class _ZilfuApi extends HeyApiClient {
|
|
1334
1335
|
static __registry = new HeyApiRegistry();
|
|
1335
1336
|
constructor(args) {
|
|
1336
1337
|
super(args);
|
|
1337
|
-
|
|
1338
|
+
_ZilfuApi.__registry.set(this, args?.key);
|
|
1338
1339
|
}
|
|
1339
1340
|
_accounts;
|
|
1340
1341
|
get accounts() {
|
|
1341
1342
|
return this._accounts ??= new Accounts({ client: this.client });
|
|
1342
1343
|
}
|
|
1343
|
-
|
|
1344
|
-
get
|
|
1345
|
-
return this.
|
|
1346
|
-
}
|
|
1347
|
-
_bioBlocks;
|
|
1348
|
-
get bioBlocks() {
|
|
1349
|
-
return this._bioBlocks ??= new BioBlocks({ client: this.client });
|
|
1344
|
+
_apiTokens;
|
|
1345
|
+
get apiTokens() {
|
|
1346
|
+
return this._apiTokens ??= new ApiTokens({ client: this.client });
|
|
1350
1347
|
}
|
|
1351
1348
|
_bio;
|
|
1352
1349
|
get bio() {
|
|
1353
1350
|
return this._bio ??= new Bio({ client: this.client });
|
|
1354
1351
|
}
|
|
1352
|
+
_health;
|
|
1353
|
+
get health() {
|
|
1354
|
+
return this._health ??= new Health({ client: this.client });
|
|
1355
|
+
}
|
|
1355
1356
|
_media;
|
|
1356
1357
|
get media() {
|
|
1357
1358
|
return this._media ??= new Media({ client: this.client });
|
|
@@ -1386,17 +1387,67 @@ var ZilfuClient = class _ZilfuClient extends HeyApiClient {
|
|
|
1386
1387
|
}
|
|
1387
1388
|
};
|
|
1388
1389
|
|
|
1390
|
+
// src/errors.ts
|
|
1391
|
+
var ZilfuApiError = class extends Error {
|
|
1392
|
+
status;
|
|
1393
|
+
statusText;
|
|
1394
|
+
url;
|
|
1395
|
+
body;
|
|
1396
|
+
errors;
|
|
1397
|
+
constructor(init) {
|
|
1398
|
+
const message = extractMessage(init);
|
|
1399
|
+
super(message);
|
|
1400
|
+
this.name = "ZilfuApiError";
|
|
1401
|
+
this.status = init.status;
|
|
1402
|
+
this.statusText = init.statusText;
|
|
1403
|
+
this.url = init.url;
|
|
1404
|
+
this.body = init.body;
|
|
1405
|
+
this.errors = extractValidationErrors(init.body);
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
function extractMessage(init) {
|
|
1409
|
+
const body = init.body;
|
|
1410
|
+
if (body && typeof body === "object" && "message" in body) {
|
|
1411
|
+
const m = body.message;
|
|
1412
|
+
if (typeof m === "string" && m.length > 0) {
|
|
1413
|
+
return m;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return `Zilfu API ${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
|
|
1417
|
+
}
|
|
1418
|
+
function extractValidationErrors(body) {
|
|
1419
|
+
if (!body || typeof body !== "object" || !("errors" in body)) {
|
|
1420
|
+
return void 0;
|
|
1421
|
+
}
|
|
1422
|
+
const errors = body.errors;
|
|
1423
|
+
if (!errors || typeof errors !== "object") {
|
|
1424
|
+
return void 0;
|
|
1425
|
+
}
|
|
1426
|
+
return errors;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1389
1429
|
// src/client.ts
|
|
1390
|
-
function createZilfuClient(
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1430
|
+
function createZilfuClient(opts) {
|
|
1431
|
+
const client2 = createClient(
|
|
1432
|
+
createConfig({
|
|
1433
|
+
baseUrl: opts.baseUrl ?? "https://zilfu.app/api",
|
|
1434
|
+
fetch: opts.fetch,
|
|
1435
|
+
headers: { accept: "application/json", ...opts.headers },
|
|
1436
|
+
auth: opts.token,
|
|
1437
|
+
throwOnError: true
|
|
1438
|
+
})
|
|
1439
|
+
);
|
|
1440
|
+
client2.interceptors.error.use((error, response) => {
|
|
1441
|
+
return new ZilfuApiError({
|
|
1442
|
+
status: response?.status ?? 0,
|
|
1443
|
+
statusText: response?.statusText,
|
|
1444
|
+
url: response?.url,
|
|
1445
|
+
body: error
|
|
1446
|
+
});
|
|
1396
1447
|
});
|
|
1397
|
-
return new
|
|
1448
|
+
return new ZilfuApi({ client: client2 });
|
|
1398
1449
|
}
|
|
1399
1450
|
|
|
1400
|
-
export {
|
|
1451
|
+
export { ZilfuApiError, createZilfuClient };
|
|
1401
1452
|
//# sourceMappingURL=index.js.map
|
|
1402
1453
|
//# sourceMappingURL=index.js.map
|