@zilfu/sdk 0.0.1 → 0.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.
package/dist/index.js CHANGED
@@ -25,14 +25,11 @@ var formDataBodySerializer = {
25
25
  }
26
26
  };
27
27
  var jsonBodySerializer = {
28
- bodySerializer: (body) => JSON.stringify(
29
- body,
30
- (_key, value) => typeof value === "bigint" ? value.toString() : value
31
- )
28
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
32
29
  };
33
30
 
34
31
  // src/generated/core/serverSentEvents.gen.ts
35
- var createSseClient = ({
32
+ function createSseClient({
36
33
  onRequest,
37
34
  onSseError,
38
35
  onSseEvent,
@@ -44,7 +41,7 @@ var createSseClient = ({
44
41
  sseSleepFn,
45
42
  url,
46
43
  ...options
47
- }) => {
44
+ }) {
48
45
  let lastEventId;
49
46
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
50
47
  const createStream = async function* () {
@@ -72,10 +69,7 @@ var createSseClient = ({
72
69
  }
73
70
  const _fetch = options.fetch ?? globalThis.fetch;
74
71
  const response = await _fetch(request);
75
- if (!response.ok)
76
- throw new Error(
77
- `SSE failed: ${response.status} ${response.statusText}`
78
- );
72
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
79
73
  if (!response.body) throw new Error("No body in SSE response");
80
74
  const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
81
75
  let buffer = "";
@@ -91,6 +85,7 @@ var createSseClient = ({
91
85
  const { done, value } = await reader.read();
92
86
  if (done) break;
93
87
  buffer += value;
88
+ buffer = buffer.replace(/\r\n?/g, "\n");
94
89
  const chunks = buffer.split("\n\n");
95
90
  buffer = chunks.pop() ?? "";
96
91
  for (const chunk of chunks) {
@@ -105,10 +100,7 @@ var createSseClient = ({
105
100
  } else if (line.startsWith("id:")) {
106
101
  lastEventId = line.replace(/^id:\s*/, "");
107
102
  } else if (line.startsWith("retry:")) {
108
- const parsed = Number.parseInt(
109
- line.replace(/^retry:\s*/, ""),
110
- 10
111
- );
103
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
112
104
  if (!Number.isNaN(parsed)) {
113
105
  retryDelay = parsed;
114
106
  }
@@ -154,17 +146,14 @@ var createSseClient = ({
154
146
  if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
155
147
  break;
156
148
  }
157
- const backoff = Math.min(
158
- retryDelay * 2 ** (attempt - 1),
159
- sseMaxRetryDelay ?? 3e4
160
- );
149
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
161
150
  await sleep(backoff);
162
151
  }
163
152
  }
164
153
  };
165
154
  const stream = createStream();
166
155
  return { stream };
167
- };
156
+ }
168
157
 
169
158
  // src/generated/core/pathSerializer.gen.ts
170
159
  var separatorArrayExplode = (style) => {
@@ -265,11 +254,7 @@ var serializeObjectParam = ({
265
254
  if (style !== "deepObject" && !explode) {
266
255
  let values = [];
267
256
  Object.entries(value).forEach(([key, v]) => {
268
- values = [
269
- ...values,
270
- key,
271
- allowReserved ? v : encodeURIComponent(v)
272
- ];
257
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
273
258
  });
274
259
  const joinedValues2 = values.join(",");
275
260
  switch (style) {
@@ -320,10 +305,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
320
305
  continue;
321
306
  }
322
307
  if (Array.isArray(value)) {
323
- url = url.replace(
324
- match,
325
- serializeArrayParam({ explode, name, style, value })
326
- );
308
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
327
309
  continue;
328
310
  }
329
311
  if (typeof value === "object") {
@@ -411,9 +393,8 @@ var getAuthToken = async (auth, callback) => {
411
393
 
412
394
  // src/generated/client/utils.gen.ts
413
395
  var createQuerySerializer = ({
414
- allowReserved,
415
- array,
416
- object
396
+ parameters = {},
397
+ ...args
417
398
  } = {}) => {
418
399
  const querySerializer = (queryParams) => {
419
400
  const search = [];
@@ -423,29 +404,30 @@ var createQuerySerializer = ({
423
404
  if (value === void 0 || value === null) {
424
405
  continue;
425
406
  }
407
+ const options = parameters[name] || args;
426
408
  if (Array.isArray(value)) {
427
409
  const serializedArray = serializeArrayParam({
428
- allowReserved,
410
+ allowReserved: options.allowReserved,
429
411
  explode: true,
430
412
  name,
431
413
  style: "form",
432
414
  value,
433
- ...array
415
+ ...options.array
434
416
  });
435
417
  if (serializedArray) search.push(serializedArray);
436
418
  } else if (typeof value === "object") {
437
419
  const serializedObject = serializeObjectParam({
438
- allowReserved,
420
+ allowReserved: options.allowReserved,
439
421
  explode: true,
440
422
  name,
441
423
  style: "deepObject",
442
424
  value,
443
- ...object
425
+ ...options.object
444
426
  });
445
427
  if (serializedObject) search.push(serializedObject);
446
428
  } else {
447
429
  const serializedPrimitive = serializePrimitiveParam({
448
- allowReserved,
430
+ allowReserved: options.allowReserved,
449
431
  name,
450
432
  value
451
433
  });
@@ -471,9 +453,7 @@ var getParseAs = (contentType) => {
471
453
  if (cleanContent === "multipart/form-data") {
472
454
  return "formData";
473
455
  }
474
- if (["application/", "audio/", "image/", "video/"].some(
475
- (type) => cleanContent.startsWith(type)
476
- )) {
456
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
477
457
  return "blob";
478
458
  }
479
459
  if (cleanContent.startsWith("text/")) {
@@ -659,108 +639,121 @@ var createClient = (config = {}) => {
659
639
  if (opts.body === void 0 || opts.serializedBody === "") {
660
640
  opts.headers.delete("Content-Type");
661
641
  }
662
- const url = buildUrl(opts);
663
- return { opts, url };
642
+ const resolvedOpts = opts;
643
+ const url = buildUrl(resolvedOpts);
644
+ return { opts: resolvedOpts, url };
664
645
  };
665
646
  const request = async (options) => {
666
- const { opts, url } = await beforeRequest(options);
667
- const requestInit = {
668
- redirect: "follow",
669
- ...opts,
670
- body: getValidRequestBody(opts)
671
- };
672
- let request2 = new Request(url, requestInit);
673
- for (const fn of interceptors.request.fns) {
674
- if (fn) {
675
- request2 = await fn(request2, opts);
647
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
648
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
649
+ let request2;
650
+ let response;
651
+ try {
652
+ const { opts, url } = await beforeRequest(options);
653
+ const requestInit = {
654
+ redirect: "follow",
655
+ ...opts,
656
+ body: getValidRequestBody(opts)
657
+ };
658
+ request2 = new Request(url, requestInit);
659
+ for (const fn of interceptors.request.fns) {
660
+ if (fn) {
661
+ request2 = await fn(request2, opts);
662
+ }
676
663
  }
677
- }
678
- const _fetch = opts.fetch;
679
- let response = await _fetch(request2);
680
- for (const fn of interceptors.response.fns) {
681
- if (fn) {
682
- response = await fn(response, request2, opts);
664
+ const _fetch = opts.fetch;
665
+ response = await _fetch(request2);
666
+ for (const fn of interceptors.response.fns) {
667
+ if (fn) {
668
+ response = await fn(response, request2, opts);
669
+ }
683
670
  }
684
- }
685
- const result = {
686
- request: request2,
687
- response
688
- };
689
- if (response.ok) {
690
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
691
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
692
- let emptyData;
671
+ const result = {
672
+ request: request2,
673
+ response
674
+ };
675
+ if (response.ok) {
676
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
677
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
678
+ let emptyData;
679
+ switch (parseAs) {
680
+ case "arrayBuffer":
681
+ case "blob":
682
+ case "text":
683
+ emptyData = await response[parseAs]();
684
+ break;
685
+ case "formData":
686
+ emptyData = new FormData();
687
+ break;
688
+ case "stream":
689
+ emptyData = response.body;
690
+ break;
691
+ case "json":
692
+ default:
693
+ emptyData = {};
694
+ break;
695
+ }
696
+ return opts.responseStyle === "data" ? emptyData : {
697
+ data: emptyData,
698
+ ...result
699
+ };
700
+ }
701
+ let data;
693
702
  switch (parseAs) {
694
703
  case "arrayBuffer":
695
704
  case "blob":
705
+ case "formData":
696
706
  case "text":
697
- emptyData = await response[parseAs]();
707
+ data = await response[parseAs]();
698
708
  break;
699
- case "formData":
700
- emptyData = new FormData();
709
+ case "json": {
710
+ const text = await response.text();
711
+ data = text ? JSON.parse(text) : {};
701
712
  break;
713
+ }
702
714
  case "stream":
703
- emptyData = response.body;
704
- break;
705
- case "json":
706
- default:
707
- emptyData = {};
708
- break;
715
+ return opts.responseStyle === "data" ? response.body : {
716
+ data: response.body,
717
+ ...result
718
+ };
719
+ }
720
+ if (parseAs === "json") {
721
+ if (opts.responseValidator) {
722
+ await opts.responseValidator(data);
723
+ }
724
+ if (opts.responseTransformer) {
725
+ data = await opts.responseTransformer(data);
726
+ }
709
727
  }
710
- return opts.responseStyle === "data" ? emptyData : {
711
- data: emptyData,
728
+ return opts.responseStyle === "data" ? data : {
729
+ data,
712
730
  ...result
713
731
  };
714
732
  }
715
- let data;
716
- switch (parseAs) {
717
- case "arrayBuffer":
718
- case "blob":
719
- case "formData":
720
- case "json":
721
- case "text":
722
- data = await response[parseAs]();
723
- break;
724
- case "stream":
725
- return opts.responseStyle === "data" ? response.body : {
726
- data: response.body,
727
- ...result
728
- };
733
+ const textError = await response.text();
734
+ let jsonError;
735
+ try {
736
+ jsonError = JSON.parse(textError);
737
+ } catch {
729
738
  }
730
- if (parseAs === "json") {
731
- if (opts.responseValidator) {
732
- await opts.responseValidator(data);
733
- }
734
- if (opts.responseTransformer) {
735
- data = await opts.responseTransformer(data);
739
+ throw jsonError ?? textError;
740
+ } catch (error) {
741
+ let finalError = error;
742
+ for (const fn of interceptors.error.fns) {
743
+ if (fn) {
744
+ finalError = await fn(finalError, response, request2, options);
736
745
  }
737
746
  }
738
- return opts.responseStyle === "data" ? data : {
739
- data,
740
- ...result
741
- };
742
- }
743
- const textError = await response.text();
744
- let jsonError;
745
- try {
746
- jsonError = JSON.parse(textError);
747
- } catch {
748
- }
749
- const error = jsonError ?? textError;
750
- let finalError = error;
751
- for (const fn of interceptors.error.fns) {
752
- if (fn) {
753
- finalError = await fn(error, response, request2, opts);
747
+ finalError = finalError || {};
748
+ if (throwOnError) {
749
+ throw finalError;
754
750
  }
751
+ return responseStyle === "data" ? void 0 : {
752
+ error: finalError,
753
+ request: request2,
754
+ response
755
+ };
755
756
  }
756
- finalError = finalError || {};
757
- if (opts.throwOnError) {
758
- throw finalError;
759
- }
760
- return opts.responseStyle === "data" ? void 0 : {
761
- error: finalError,
762
- ...result
763
- };
764
757
  };
765
758
  const makeMethodFn = (method) => (options) => request({ ...options, method });
766
759
  const makeSseFn = (method) => async (options) => {
@@ -768,7 +761,6 @@ var createClient = (config = {}) => {
768
761
  return createSseClient({
769
762
  ...opts,
770
763
  body: opts.body,
771
- headers: opts.headers,
772
764
  method,
773
765
  onRequest: async (url2, init) => {
774
766
  let request2 = new Request(url2, init);
@@ -779,11 +771,13 @@ var createClient = (config = {}) => {
779
771
  }
780
772
  return request2;
781
773
  },
774
+ serializedBody: getValidRequestBody(opts),
782
775
  url
783
776
  });
784
777
  };
778
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
785
779
  return {
786
- buildUrl,
780
+ buildUrl: _buildUrl,
787
781
  connect: makeMethodFn("CONNECT"),
788
782
  delete: makeMethodFn("DELETE"),
789
783
  get: makeMethodFn("GET"),
@@ -812,544 +806,597 @@ var createClient = (config = {}) => {
812
806
  };
813
807
 
814
808
  // src/generated/client.gen.ts
815
- var client = createClient(createConfig({
816
- baseUrl: "https://zilfu.app/api"
817
- }));
818
-
819
- // src/client.ts
820
- function createZilfuClient(options) {
821
- const { baseUrl, token, fetch: fetchImpl } = options;
822
- client.setConfig({
823
- baseUrl,
824
- auth: typeof token === "function" ? token : token,
825
- ...fetchImpl ? { fetch: fetchImpl } : {}
826
- });
827
- }
809
+ var client = createClient(createConfig({ baseUrl: "https://zilfu.app/api" }));
828
810
 
829
811
  // src/generated/sdk.gen.ts
830
- var accountsDestroyMany = (options) => {
831
- return (options.client ?? client).delete({
832
- security: [
833
- {
834
- scheme: "bearer",
835
- type: "http"
836
- }
837
- ],
838
- url: "/spaces/{space}/accounts",
839
- ...options
840
- });
841
- };
842
- var accountsIndex = (options) => {
843
- return (options.client ?? client).get({
844
- security: [
845
- {
846
- scheme: "bearer",
847
- type: "http"
848
- }
849
- ],
850
- url: "/spaces/{space}/accounts",
851
- ...options
852
- });
853
- };
854
- var accountsActivate = (options) => {
855
- return (options.client ?? client).patch({
856
- security: [
857
- {
858
- scheme: "bearer",
859
- type: "http"
860
- }
861
- ],
862
- url: "/spaces/{space}/accounts/{account}/activate",
863
- ...options
864
- });
865
- };
866
- var accountsBoards = (options) => {
867
- return (options.client ?? client).get({
868
- security: [
869
- {
870
- scheme: "bearer",
871
- type: "http"
872
- }
873
- ],
874
- url: "/spaces/{space}/accounts/{account}/boards",
875
- ...options
876
- });
877
- };
878
- var accountsDestroy = (options) => {
879
- return (options.client ?? client).delete({
880
- security: [
881
- {
882
- scheme: "bearer",
883
- type: "http"
884
- }
885
- ],
886
- url: "/spaces/{space}/accounts/{account}",
887
- ...options
888
- });
889
- };
890
- var apiTokensStore = (options) => {
891
- return (options.client ?? client).post({
892
- security: [
893
- {
894
- scheme: "bearer",
895
- type: "http"
896
- }
897
- ],
898
- url: "/api-tokens",
899
- ...options,
900
- headers: {
901
- "Content-Type": "application/json",
902
- ...options.headers
903
- }
904
- });
905
- };
906
- var apiTokensDestroy = (options) => {
907
- return (options.client ?? client).delete({
908
- security: [
909
- {
910
- scheme: "bearer",
911
- type: "http"
912
- }
913
- ],
914
- url: "/api-tokens/{tokenId}",
915
- ...options
916
- });
917
- };
918
- var bioBlocksIndex = (options) => {
919
- return (options.client ?? client).get({
920
- security: [
921
- {
922
- scheme: "bearer",
923
- type: "http"
924
- }
925
- ],
926
- url: "/spaces/{space}/bio/blocks",
927
- ...options
928
- });
929
- };
930
- var bioBlocksStore = (options) => {
931
- return (options.client ?? client).post({
932
- security: [
933
- {
934
- scheme: "bearer",
935
- type: "http"
936
- }
937
- ],
938
- url: "/spaces/{space}/bio/blocks",
939
- ...options,
940
- headers: {
941
- "Content-Type": "application/json",
942
- ...options.headers
943
- }
944
- });
945
- };
946
- var bioBlocksDestroy = (options) => {
947
- return (options.client ?? client).delete({
948
- security: [
949
- {
950
- scheme: "bearer",
951
- type: "http"
952
- }
953
- ],
954
- url: "/spaces/{space}/bio/blocks/{block}",
955
- ...options
956
- });
957
- };
958
- var bioBlocksUpdate = (options) => {
959
- return (options.client ?? client).put({
960
- security: [
961
- {
962
- scheme: "bearer",
963
- type: "http"
964
- }
965
- ],
966
- url: "/spaces/{space}/bio/blocks/{block}",
967
- ...options,
968
- headers: {
969
- "Content-Type": "application/json",
970
- ...options.headers
971
- }
972
- });
973
- };
974
- var bioBlocksReorder = (options) => {
975
- return (options.client ?? client).post({
976
- security: [
977
- {
978
- scheme: "bearer",
979
- type: "http"
980
- }
981
- ],
982
- url: "/spaces/{space}/bio/blocks/{block}/reorder",
983
- ...options,
984
- headers: {
985
- "Content-Type": "application/json",
986
- ...options.headers
987
- }
988
- });
989
- };
990
- var bioShow = (options) => {
991
- return (options.client ?? client).get({
992
- security: [
993
- {
994
- scheme: "bearer",
995
- type: "http"
996
- }
997
- ],
998
- url: "/spaces/{space}/bio",
999
- ...options
1000
- });
1001
- };
1002
- var bioStore = (options) => {
1003
- return (options.client ?? client).post({
1004
- security: [
1005
- {
1006
- scheme: "bearer",
1007
- type: "http"
1008
- }
1009
- ],
1010
- url: "/spaces/{space}/bio",
1011
- ...options,
1012
- headers: {
1013
- "Content-Type": "application/json",
1014
- ...options.headers
1015
- }
1016
- });
1017
- };
1018
- var bioUpdate = (options) => {
1019
- return (options.client ?? client).put({
1020
- security: [
1021
- {
1022
- scheme: "bearer",
1023
- type: "http"
1024
- }
1025
- ],
1026
- url: "/spaces/{space}/bio",
1027
- ...options,
1028
- headers: {
1029
- "Content-Type": "application/json",
1030
- ...options.headers
1031
- }
1032
- });
1033
- };
1034
- var bioAvatar = (options) => {
1035
- return (options.client ?? client).post({
1036
- ...formDataBodySerializer,
1037
- security: [
1038
- {
1039
- scheme: "bearer",
1040
- type: "http"
1041
- }
1042
- ],
1043
- url: "/spaces/{space}/bio/avatar",
1044
- ...options,
1045
- headers: {
1046
- "Content-Type": null,
1047
- ...options.headers
1048
- }
1049
- });
812
+ var HeyApiClient = class {
813
+ client;
814
+ constructor(args) {
815
+ this.client = args?.client ?? client;
816
+ }
1050
817
  };
1051
- var mediaStore = (options) => {
1052
- return (options.client ?? client).post({
1053
- ...formDataBodySerializer,
1054
- security: [
1055
- {
1056
- scheme: "bearer",
1057
- type: "http"
1058
- }
1059
- ],
1060
- url: "/media",
1061
- ...options,
1062
- headers: {
1063
- "Content-Type": null,
1064
- ...options.headers
818
+ var HeyApiRegistry = class {
819
+ defaultKey = "default";
820
+ instances = /* @__PURE__ */ new Map();
821
+ get(key) {
822
+ const instance = this.instances.get(key ?? this.defaultKey);
823
+ if (!instance) {
824
+ throw new Error(`No SDK client found. Create one with "new ZilfuClient()" to fix this error.`);
1065
825
  }
1066
- });
826
+ return instance;
827
+ }
828
+ set(value, key) {
829
+ this.instances.set(key ?? this.defaultKey, value);
830
+ }
1067
831
  };
1068
- var mediaDestroy = (options) => {
1069
- return (options.client ?? client).delete({
1070
- security: [
1071
- {
1072
- scheme: "bearer",
1073
- type: "http"
1074
- }
1075
- ],
1076
- url: "/media/{media}",
1077
- ...options
1078
- });
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
+ /**
846
+ * List accounts
847
+ *
848
+ * Returns all connected social accounts for the given space.
849
+ */
850
+ list(options) {
851
+ return (options.client ?? this.client).get({
852
+ security: [{ scheme: "bearer", type: "http" }],
853
+ url: "/spaces/{space}/accounts",
854
+ ...options
855
+ });
856
+ }
857
+ /**
858
+ * Activate an account
859
+ *
860
+ * Activates the given account and deactivates all other accounts on the same platform within the space.
861
+ */
862
+ activate(options) {
863
+ return (options.client ?? this.client).patch({
864
+ security: [{ scheme: "bearer", type: "http" }],
865
+ url: "/spaces/{space}/accounts/{account}/activate",
866
+ ...options
867
+ });
868
+ }
869
+ /**
870
+ * List Pinterest boards
871
+ *
872
+ * Returns the Pinterest boards available for the given account.
873
+ */
874
+ boards(options) {
875
+ return (options.client ?? this.client).get({
876
+ security: [{ scheme: "bearer", type: "http" }],
877
+ url: "/spaces/{space}/accounts/{account}/boards",
878
+ ...options
879
+ });
880
+ }
881
+ /**
882
+ * Disconnect an account
883
+ *
884
+ * Removes the social account connection and dispatches a webhook event.
885
+ */
886
+ delete(options) {
887
+ return (options.client ?? this.client).delete({
888
+ security: [{ scheme: "bearer", type: "http" }],
889
+ url: "/spaces/{space}/accounts/{account}",
890
+ ...options
891
+ });
892
+ }
1079
893
  };
1080
- var postsIndex = (options) => {
1081
- return (options.client ?? client).get({
1082
- security: [
1083
- {
1084
- scheme: "bearer",
1085
- type: "http"
894
+ var Tokens = class extends HeyApiClient {
895
+ /**
896
+ * Create an API token
897
+ *
898
+ * Generates a new personal access token for the authenticated user.
899
+ */
900
+ create(options) {
901
+ return (options.client ?? this.client).post({
902
+ security: [{ scheme: "bearer", type: "http" }],
903
+ url: "/api-tokens",
904
+ ...options,
905
+ headers: {
906
+ "Content-Type": "application/json",
907
+ ...options.headers
1086
908
  }
1087
- ],
1088
- url: "/spaces/{space}/posts",
1089
- ...options
1090
- });
909
+ });
910
+ }
911
+ /**
912
+ * Revoke an API token
913
+ *
914
+ * Deletes the specified personal access token.
915
+ */
916
+ delete(options) {
917
+ return (options.client ?? this.client).delete({
918
+ security: [{ scheme: "bearer", type: "http" }],
919
+ url: "/api-tokens/{tokenId}",
920
+ ...options
921
+ });
922
+ }
1091
923
  };
1092
- var postsStore = (options) => {
1093
- return (options.client ?? client).post({
1094
- security: [
1095
- {
1096
- scheme: "bearer",
1097
- type: "http"
924
+ var BioBlocks = class extends HeyApiClient {
925
+ list(options) {
926
+ return (options.client ?? this.client).get({
927
+ security: [{ scheme: "bearer", type: "http" }],
928
+ url: "/spaces/{space}/bio/blocks",
929
+ ...options
930
+ });
931
+ }
932
+ create(options) {
933
+ return (options.client ?? this.client).post({
934
+ security: [{ scheme: "bearer", type: "http" }],
935
+ url: "/spaces/{space}/bio/blocks",
936
+ ...options,
937
+ headers: {
938
+ "Content-Type": "application/json",
939
+ ...options.headers
1098
940
  }
1099
- ],
1100
- url: "/spaces/{space}/posts",
1101
- ...options,
1102
- headers: {
1103
- "Content-Type": "application/json",
1104
- ...options.headers
1105
- }
1106
- });
1107
- };
1108
- var postsDestroy = (options) => {
1109
- return (options.client ?? client).delete({
1110
- security: [
1111
- {
1112
- scheme: "bearer",
1113
- type: "http"
941
+ });
942
+ }
943
+ delete(options) {
944
+ return (options.client ?? this.client).delete({
945
+ security: [{ scheme: "bearer", type: "http" }],
946
+ url: "/spaces/{space}/bio/blocks/{block}",
947
+ ...options
948
+ });
949
+ }
950
+ update(options) {
951
+ return (options.client ?? this.client).put({
952
+ security: [{ scheme: "bearer", type: "http" }],
953
+ url: "/spaces/{space}/bio/blocks/{block}",
954
+ ...options,
955
+ headers: {
956
+ "Content-Type": "application/json",
957
+ ...options.headers
1114
958
  }
1115
- ],
1116
- url: "/spaces/{space}/posts/{post}",
1117
- ...options
1118
- });
1119
- };
1120
- var postsShow = (options) => {
1121
- return (options.client ?? client).get({
1122
- security: [
1123
- {
1124
- scheme: "bearer",
1125
- type: "http"
959
+ });
960
+ }
961
+ reorder(options) {
962
+ return (options.client ?? this.client).post({
963
+ security: [{ scheme: "bearer", type: "http" }],
964
+ url: "/spaces/{space}/bio/blocks/{block}/reorder",
965
+ ...options,
966
+ headers: {
967
+ "Content-Type": "application/json",
968
+ ...options.headers
1126
969
  }
1127
- ],
1128
- url: "/spaces/{space}/posts/{post}",
1129
- ...options
1130
- });
970
+ });
971
+ }
1131
972
  };
1132
- var postsUpdate = (options) => {
1133
- return (options.client ?? client).put({
1134
- security: [
1135
- {
1136
- scheme: "bearer",
1137
- type: "http"
973
+ var Bio = class extends HeyApiClient {
974
+ get(options) {
975
+ return (options.client ?? this.client).get({
976
+ security: [{ scheme: "bearer", type: "http" }],
977
+ url: "/spaces/{space}/bio",
978
+ ...options
979
+ });
980
+ }
981
+ create(options) {
982
+ return (options.client ?? this.client).post({
983
+ security: [{ scheme: "bearer", type: "http" }],
984
+ url: "/spaces/{space}/bio",
985
+ ...options,
986
+ headers: {
987
+ "Content-Type": "application/json",
988
+ ...options.headers
1138
989
  }
1139
- ],
1140
- url: "/spaces/{space}/posts/{post}",
1141
- ...options,
1142
- headers: {
1143
- "Content-Type": "application/json",
1144
- ...options.headers
1145
- }
1146
- });
1147
- };
1148
- var clustersUpdate = (options) => {
1149
- return (options.client ?? client).put({
1150
- security: [
1151
- {
1152
- scheme: "bearer",
1153
- type: "http"
990
+ });
991
+ }
992
+ update(options) {
993
+ return (options.client ?? this.client).put({
994
+ security: [{ scheme: "bearer", type: "http" }],
995
+ url: "/spaces/{space}/bio",
996
+ ...options,
997
+ headers: {
998
+ "Content-Type": "application/json",
999
+ ...options.headers
1154
1000
  }
1155
- ],
1156
- url: "/spaces/{space}/clusters/{cluster_id}",
1157
- ...options,
1158
- headers: {
1159
- "Content-Type": "application/json",
1160
- ...options.headers
1161
- }
1162
- });
1163
- };
1164
- var queueIndex = (options) => {
1165
- return (options.client ?? client).get({
1166
- security: [
1167
- {
1168
- scheme: "bearer",
1169
- type: "http"
1001
+ });
1002
+ }
1003
+ uploadAvatar(options) {
1004
+ return (options.client ?? this.client).post({
1005
+ ...formDataBodySerializer,
1006
+ security: [{ scheme: "bearer", type: "http" }],
1007
+ url: "/spaces/{space}/bio/avatar",
1008
+ ...options,
1009
+ headers: {
1010
+ "Content-Type": null,
1011
+ ...options.headers
1170
1012
  }
1171
- ],
1172
- url: "/spaces/{space}/queue",
1173
- ...options
1174
- });
1013
+ });
1014
+ }
1175
1015
  };
1176
- var slotsIndex = (options) => {
1177
- return (options.client ?? client).get({
1178
- security: [
1179
- {
1180
- scheme: "bearer",
1181
- type: "http"
1016
+ var Media = class extends HeyApiClient {
1017
+ /**
1018
+ * Upload a media file
1019
+ *
1020
+ * Accepts images (JPEG, PNG, WebP) and videos (MP4, QuickTime). Images are auto-optimized.
1021
+ */
1022
+ create(options) {
1023
+ return (options.client ?? this.client).post({
1024
+ ...formDataBodySerializer,
1025
+ security: [{ scheme: "bearer", type: "http" }],
1026
+ url: "/media",
1027
+ ...options,
1028
+ headers: {
1029
+ "Content-Type": null,
1030
+ ...options.headers
1182
1031
  }
1183
- ],
1184
- url: "/spaces/{space}/slots",
1185
- ...options
1186
- });
1032
+ });
1033
+ }
1034
+ /**
1035
+ * Delete a media file
1036
+ *
1037
+ * Removes the media file from storage and deletes the record.
1038
+ */
1039
+ delete(options) {
1040
+ return (options.client ?? this.client).delete({
1041
+ security: [{ scheme: "bearer", type: "http" }],
1042
+ url: "/media/{media}",
1043
+ ...options
1044
+ });
1045
+ }
1187
1046
  };
1188
- var slotsStore = (options) => {
1189
- return (options.client ?? client).post({
1190
- security: [
1191
- {
1192
- scheme: "bearer",
1193
- type: "http"
1047
+ var Posts = class extends HeyApiClient {
1048
+ /**
1049
+ * List posts
1050
+ *
1051
+ * Returns paginated posts for the space. Filterable by status, account, and date range via query parameters.
1052
+ */
1053
+ list(options) {
1054
+ return (options.client ?? this.client).get({
1055
+ security: [{ scheme: "bearer", type: "http" }],
1056
+ url: "/spaces/{space}/posts",
1057
+ ...options
1058
+ });
1059
+ }
1060
+ /**
1061
+ * Create posts
1062
+ *
1063
+ * Creates one or more posts as a cluster. Supports draft, scheduled, or immediate publishing modes.
1064
+ */
1065
+ create(options) {
1066
+ return (options.client ?? this.client).post({
1067
+ security: [{ scheme: "bearer", type: "http" }],
1068
+ url: "/spaces/{space}/posts",
1069
+ ...options,
1070
+ headers: {
1071
+ "Content-Type": "application/json",
1072
+ ...options.headers
1194
1073
  }
1195
- ],
1196
- url: "/spaces/{space}/slots",
1197
- ...options,
1198
- headers: {
1199
- "Content-Type": "application/json",
1200
- ...options.headers
1201
- }
1202
- });
1203
- };
1204
- var slotsDestroy = (options) => {
1205
- return (options.client ?? client).delete({
1206
- security: [
1207
- {
1208
- scheme: "bearer",
1209
- type: "http"
1074
+ });
1075
+ }
1076
+ /**
1077
+ * Delete a post
1078
+ *
1079
+ * Permanently deletes the given post.
1080
+ */
1081
+ delete(options) {
1082
+ return (options.client ?? this.client).delete({
1083
+ security: [{ scheme: "bearer", type: "http" }],
1084
+ url: "/spaces/{space}/posts/{post}",
1085
+ ...options
1086
+ });
1087
+ }
1088
+ /**
1089
+ * Get a post
1090
+ *
1091
+ * Returns a single post with its account, children, and media.
1092
+ */
1093
+ get(options) {
1094
+ return (options.client ?? this.client).get({
1095
+ security: [{ scheme: "bearer", type: "http" }],
1096
+ url: "/spaces/{space}/posts/{post}",
1097
+ ...options
1098
+ });
1099
+ }
1100
+ /**
1101
+ * Update a post
1102
+ *
1103
+ * Updates a single post's content, schedule, and media attachments.
1104
+ */
1105
+ update(options) {
1106
+ return (options.client ?? this.client).put({
1107
+ security: [{ scheme: "bearer", type: "http" }],
1108
+ url: "/spaces/{space}/posts/{post}",
1109
+ ...options,
1110
+ headers: {
1111
+ "Content-Type": "application/json",
1112
+ ...options.headers
1210
1113
  }
1211
- ],
1212
- url: "/spaces/{space}/slots/{slot}",
1213
- ...options
1214
- });
1114
+ });
1115
+ }
1215
1116
  };
1216
- var spacesIndex = (options) => {
1217
- return (options?.client ?? client).get({
1218
- security: [
1219
- {
1220
- scheme: "bearer",
1221
- type: "http"
1117
+ var Clusters = class extends HeyApiClient {
1118
+ /**
1119
+ * Update a cluster of posts
1120
+ *
1121
+ * Updates all posts sharing the given cluster ID. Handles adding/removing accounts and re-scheduling.
1122
+ */
1123
+ update(options) {
1124
+ return (options.client ?? this.client).put({
1125
+ security: [{ scheme: "bearer", type: "http" }],
1126
+ url: "/spaces/{space}/clusters/{cluster_id}",
1127
+ ...options,
1128
+ headers: {
1129
+ "Content-Type": "application/json",
1130
+ ...options.headers
1222
1131
  }
1223
- ],
1224
- url: "/spaces",
1225
- ...options
1226
- });
1132
+ });
1133
+ }
1227
1134
  };
1228
- var spacesStore = (options) => {
1229
- return (options.client ?? client).post({
1230
- security: [
1231
- {
1232
- scheme: "bearer",
1233
- type: "http"
1234
- }
1235
- ],
1236
- url: "/spaces",
1237
- ...options,
1238
- headers: {
1239
- "Content-Type": "application/json",
1240
- ...options.headers
1241
- }
1242
- });
1135
+ var Queue = class extends HeyApiClient {
1136
+ /**
1137
+ * Get next available queue slots
1138
+ *
1139
+ * Returns up to 9 upcoming available time slots based on the space's scheduling configuration.
1140
+ */
1141
+ list(options) {
1142
+ return (options.client ?? this.client).get({
1143
+ security: [{ scheme: "bearer", type: "http" }],
1144
+ url: "/spaces/{space}/queue",
1145
+ ...options
1146
+ });
1147
+ }
1243
1148
  };
1244
- var spacesDestroy = (options) => {
1245
- return (options.client ?? client).delete({
1246
- security: [
1247
- {
1248
- scheme: "bearer",
1249
- type: "http"
1149
+ var Slots = class extends HeyApiClient {
1150
+ /**
1151
+ * List slots
1152
+ *
1153
+ * Returns all scheduling slots for the space, ordered by day and time.
1154
+ */
1155
+ list(options) {
1156
+ return (options.client ?? this.client).get({
1157
+ security: [{ scheme: "bearer", type: "http" }],
1158
+ url: "/spaces/{space}/slots",
1159
+ ...options
1160
+ });
1161
+ }
1162
+ /**
1163
+ * Create slots
1164
+ *
1165
+ * Creates scheduling slots for the given days of the week and time.
1166
+ */
1167
+ create(options) {
1168
+ return (options.client ?? this.client).post({
1169
+ security: [{ scheme: "bearer", type: "http" }],
1170
+ url: "/spaces/{space}/slots",
1171
+ ...options,
1172
+ headers: {
1173
+ "Content-Type": "application/json",
1174
+ ...options.headers
1250
1175
  }
1251
- ],
1252
- url: "/spaces/{space}",
1253
- ...options
1254
- });
1176
+ });
1177
+ }
1178
+ /**
1179
+ * Delete a slot
1180
+ *
1181
+ * Removes a scheduling slot from the space.
1182
+ */
1183
+ delete(options) {
1184
+ return (options.client ?? this.client).delete({
1185
+ security: [{ scheme: "bearer", type: "http" }],
1186
+ url: "/spaces/{space}/slots/{slot}",
1187
+ ...options
1188
+ });
1189
+ }
1255
1190
  };
1256
- var spacesShow = (options) => {
1257
- return (options.client ?? client).get({
1258
- security: [
1259
- {
1260
- scheme: "bearer",
1261
- type: "http"
1191
+ var Spaces = class extends HeyApiClient {
1192
+ /**
1193
+ * List spaces
1194
+ *
1195
+ * Returns all spaces belonging to the authenticated user, ordered by most recent.
1196
+ */
1197
+ list(options) {
1198
+ return (options?.client ?? this.client).get({
1199
+ security: [{ scheme: "bearer", type: "http" }],
1200
+ url: "/spaces",
1201
+ ...options
1202
+ });
1203
+ }
1204
+ /**
1205
+ * Create a space
1206
+ *
1207
+ * Creates a new space for the authenticated user.
1208
+ */
1209
+ create(options) {
1210
+ return (options.client ?? this.client).post({
1211
+ security: [{ scheme: "bearer", type: "http" }],
1212
+ url: "/spaces",
1213
+ ...options,
1214
+ headers: {
1215
+ "Content-Type": "application/json",
1216
+ ...options.headers
1262
1217
  }
1263
- ],
1264
- url: "/spaces/{space}",
1265
- ...options
1266
- });
1267
- };
1268
- var spacesUpdate = (options) => {
1269
- return (options.client ?? client).put({
1270
- security: [
1271
- {
1272
- scheme: "bearer",
1273
- type: "http"
1218
+ });
1219
+ }
1220
+ /**
1221
+ * Delete a space
1222
+ *
1223
+ * Permanently deletes the given space and all associated data.
1224
+ */
1225
+ delete(options) {
1226
+ return (options.client ?? this.client).delete({
1227
+ security: [{ scheme: "bearer", type: "http" }],
1228
+ url: "/spaces/{space}",
1229
+ ...options
1230
+ });
1231
+ }
1232
+ /**
1233
+ * Get a space
1234
+ *
1235
+ * Returns a single space by ID.
1236
+ */
1237
+ get(options) {
1238
+ return (options.client ?? this.client).get({
1239
+ security: [{ scheme: "bearer", type: "http" }],
1240
+ url: "/spaces/{space}",
1241
+ ...options
1242
+ });
1243
+ }
1244
+ /**
1245
+ * Update a space
1246
+ *
1247
+ * Updates the given space's settings.
1248
+ */
1249
+ update(options) {
1250
+ return (options.client ?? this.client).put({
1251
+ security: [{ scheme: "bearer", type: "http" }],
1252
+ url: "/spaces/{space}",
1253
+ ...options,
1254
+ headers: {
1255
+ "Content-Type": "application/json",
1256
+ ...options.headers
1274
1257
  }
1275
- ],
1276
- url: "/spaces/{space}",
1277
- ...options,
1278
- headers: {
1279
- "Content-Type": "application/json",
1280
- ...options.headers
1281
- }
1282
- });
1258
+ });
1259
+ }
1283
1260
  };
1284
- var subscriptionShow = (options) => {
1285
- return (options?.client ?? client).get({
1286
- security: [
1287
- {
1288
- scheme: "bearer",
1289
- type: "http"
1290
- }
1291
- ],
1292
- url: "/subscription",
1293
- ...options
1294
- });
1261
+ var Subscription = class extends HeyApiClient {
1262
+ /**
1263
+ * Get subscription details
1264
+ *
1265
+ * Returns the current plan, usage limits, trial status, and cancellation state.
1266
+ */
1267
+ get(options) {
1268
+ return (options?.client ?? this.client).get({
1269
+ security: [{ scheme: "bearer", type: "http" }],
1270
+ url: "/subscription",
1271
+ ...options
1272
+ });
1273
+ }
1295
1274
  };
1296
- var webhooksIndex = (options) => {
1297
- return (options.client ?? client).get({
1298
- security: [
1299
- {
1300
- scheme: "bearer",
1301
- type: "http"
1275
+ var Webhooks = class extends HeyApiClient {
1276
+ /**
1277
+ * List webhooks
1278
+ *
1279
+ * Returns all webhooks configured for the given space.
1280
+ */
1281
+ list(options) {
1282
+ return (options.client ?? this.client).get({
1283
+ security: [{ scheme: "bearer", type: "http" }],
1284
+ url: "/spaces/{space}/webhooks",
1285
+ ...options
1286
+ });
1287
+ }
1288
+ /**
1289
+ * Create a webhook
1290
+ *
1291
+ * Registers a new webhook endpoint with an auto-generated signing secret.
1292
+ */
1293
+ create(options) {
1294
+ return (options.client ?? this.client).post({
1295
+ security: [{ scheme: "bearer", type: "http" }],
1296
+ url: "/spaces/{space}/webhooks",
1297
+ ...options,
1298
+ headers: {
1299
+ "Content-Type": "application/json",
1300
+ ...options.headers
1302
1301
  }
1303
- ],
1304
- url: "/spaces/{space}/webhooks",
1305
- ...options
1306
- });
1307
- };
1308
- var webhooksStore = (options) => {
1309
- return (options.client ?? client).post({
1310
- security: [
1311
- {
1312
- scheme: "bearer",
1313
- type: "http"
1302
+ });
1303
+ }
1304
+ /**
1305
+ * Delete a webhook
1306
+ *
1307
+ * Permanently removes the webhook endpoint.
1308
+ */
1309
+ delete(options) {
1310
+ return (options.client ?? this.client).delete({
1311
+ security: [{ scheme: "bearer", type: "http" }],
1312
+ url: "/spaces/{space}/webhooks/{webhook}",
1313
+ ...options
1314
+ });
1315
+ }
1316
+ /**
1317
+ * Update a webhook
1318
+ *
1319
+ * Updates the webhook's URL, events, or active status.
1320
+ */
1321
+ update(options) {
1322
+ return (options.client ?? this.client).put({
1323
+ security: [{ scheme: "bearer", type: "http" }],
1324
+ url: "/spaces/{space}/webhooks/{webhook}",
1325
+ ...options,
1326
+ headers: {
1327
+ "Content-Type": "application/json",
1328
+ ...options.headers
1314
1329
  }
1315
- ],
1316
- url: "/spaces/{space}/webhooks",
1317
- ...options,
1318
- headers: {
1319
- "Content-Type": "application/json",
1320
- ...options.headers
1321
- }
1322
- });
1330
+ });
1331
+ }
1323
1332
  };
1324
- var webhooksDestroy = (options) => {
1325
- return (options.client ?? client).delete({
1326
- security: [
1327
- {
1328
- scheme: "bearer",
1329
- type: "http"
1330
- }
1331
- ],
1332
- url: "/spaces/{space}/webhooks/{webhook}",
1333
- ...options
1334
- });
1333
+ var ZilfuClient = class _ZilfuClient extends HeyApiClient {
1334
+ static __registry = new HeyApiRegistry();
1335
+ constructor(args) {
1336
+ super(args);
1337
+ _ZilfuClient.__registry.set(this, args?.key);
1338
+ }
1339
+ _accounts;
1340
+ get accounts() {
1341
+ return this._accounts ??= new Accounts({ client: this.client });
1342
+ }
1343
+ _tokens;
1344
+ get tokens() {
1345
+ return this._tokens ??= new Tokens({ client: this.client });
1346
+ }
1347
+ _bioBlocks;
1348
+ get bioBlocks() {
1349
+ return this._bioBlocks ??= new BioBlocks({ client: this.client });
1350
+ }
1351
+ _bio;
1352
+ get bio() {
1353
+ return this._bio ??= new Bio({ client: this.client });
1354
+ }
1355
+ _media;
1356
+ get media() {
1357
+ return this._media ??= new Media({ client: this.client });
1358
+ }
1359
+ _posts;
1360
+ get posts() {
1361
+ return this._posts ??= new Posts({ client: this.client });
1362
+ }
1363
+ _clusters;
1364
+ get clusters() {
1365
+ return this._clusters ??= new Clusters({ client: this.client });
1366
+ }
1367
+ _queue;
1368
+ get queue() {
1369
+ return this._queue ??= new Queue({ client: this.client });
1370
+ }
1371
+ _slots;
1372
+ get slots() {
1373
+ return this._slots ??= new Slots({ client: this.client });
1374
+ }
1375
+ _spaces;
1376
+ get spaces() {
1377
+ return this._spaces ??= new Spaces({ client: this.client });
1378
+ }
1379
+ _subscription;
1380
+ get subscription() {
1381
+ return this._subscription ??= new Subscription({ client: this.client });
1382
+ }
1383
+ _webhooks;
1384
+ get webhooks() {
1385
+ return this._webhooks ??= new Webhooks({ client: this.client });
1386
+ }
1335
1387
  };
1336
- var webhooksUpdate = (options) => {
1337
- return (options.client ?? client).put({
1338
- security: [
1339
- {
1340
- scheme: "bearer",
1341
- type: "http"
1342
- }
1343
- ],
1344
- url: "/spaces/{space}/webhooks/{webhook}",
1345
- ...options,
1346
- headers: {
1347
- "Content-Type": "application/json",
1348
- ...options.headers
1349
- }
1388
+
1389
+ // src/client.ts
1390
+ function createZilfuClient(options) {
1391
+ const { baseUrl, token, fetch: fetchImpl } = options;
1392
+ client.setConfig({
1393
+ baseUrl,
1394
+ auth: token,
1395
+ ...fetchImpl ? { fetch: fetchImpl } : {}
1350
1396
  });
1351
- };
1397
+ return new ZilfuClient();
1398
+ }
1352
1399
 
1353
- export { accountsActivate, accountsBoards, accountsDestroy, accountsDestroyMany, accountsIndex, apiTokensDestroy, apiTokensStore, bioAvatar, bioBlocksDestroy, bioBlocksIndex, bioBlocksReorder, bioBlocksStore, bioBlocksUpdate, bioShow, bioStore, bioUpdate, client, clustersUpdate, createZilfuClient, mediaDestroy, mediaStore, postsDestroy, postsIndex, postsShow, postsStore, postsUpdate, queueIndex, slotsDestroy, slotsIndex, slotsStore, spacesDestroy, spacesIndex, spacesShow, spacesStore, spacesUpdate, subscriptionShow, webhooksDestroy, webhooksIndex, webhooksStore, webhooksUpdate };
1400
+ export { Accounts, Bio, BioBlocks, Clusters, Media, Posts, Queue, Slots, Spaces, Subscription, Tokens, Webhooks, ZilfuClient, client, createZilfuClient };
1354
1401
  //# sourceMappingURL=index.js.map
1355
1402
  //# sourceMappingURL=index.js.map