@naturali/sdk 0.40.1 → 0.41.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.cjs CHANGED
@@ -1833,6 +1833,126 @@ var Traces = class {
1833
1833
  });
1834
1834
  }
1835
1835
  };
1836
+ var Webhooks = class {
1837
+ /**
1838
+ * List webhooks
1839
+ *
1840
+ * The endpoints registered in the project, newest first.
1841
+ */
1842
+ static listWebhooks(options) {
1843
+ return (options.client ?? client).get({
1844
+ url: "/v1/projects/{project_id}/webhooks",
1845
+ ...options
1846
+ });
1847
+ }
1848
+ /**
1849
+ * Create a webhook
1850
+ *
1851
+ * Register an endpoint and subscribe it to one or more event types.
1852
+ * The response carries `secret` — the signing key, in plaintext. **This is the only time it is returned.** Store it where your receiver can read it; if you lose it, rotate rather than re-create, so the endpoint keeps its delivery history.
1853
+ * Returns `501` on a deployment with no credential-sealing key configured, since the secret could not then be stored safely.
1854
+ *
1855
+ */
1856
+ static createWebhook(options) {
1857
+ return (options.client ?? client).post({
1858
+ url: "/v1/projects/{project_id}/webhooks",
1859
+ ...options,
1860
+ headers: {
1861
+ "Content-Type": "application/json",
1862
+ ...options.headers
1863
+ }
1864
+ });
1865
+ }
1866
+ /**
1867
+ * Delete a webhook
1868
+ *
1869
+ * Removes the endpoint and its delivery records. To stop deliveries while keeping the audit trail, `PATCH` it to `active: false` instead.
1870
+ *
1871
+ */
1872
+ static deleteWebhook(options) {
1873
+ return (options.client ?? client).delete({
1874
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1875
+ ...options
1876
+ });
1877
+ }
1878
+ /**
1879
+ * Get a webhook
1880
+ */
1881
+ static getWebhook(options) {
1882
+ return (options.client ?? client).get({
1883
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1884
+ ...options
1885
+ });
1886
+ }
1887
+ /**
1888
+ * Update a webhook
1889
+ *
1890
+ * Change the destination, the subscription, the label, or whether deliveries are attempted at all. At least one field is required.
1891
+ * Setting `active: false` is the reversible half of `DELETE`: deliveries stop, the endpoint and its history stay. It is what to reach for while a receiver is being repaired.
1892
+ *
1893
+ */
1894
+ static updateWebhook(options) {
1895
+ return (options.client ?? client).patch({
1896
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1897
+ ...options,
1898
+ headers: {
1899
+ "Content-Type": "application/json",
1900
+ ...options.headers
1901
+ }
1902
+ });
1903
+ }
1904
+ /**
1905
+ * Rotate the signing secret
1906
+ *
1907
+ * Issues a new signing secret for the same endpoint and returns it — the second and last time a secret is ever returned. This is the `…:rotate-secret` action; the path segment is `{webhook_id}:rotate-secret`.
1908
+ * The change takes effect on the next delivery, including retries of deliveries already queued, so roll the new secret out to your receiver promptly. There is no overlap window in which both secrets verify.
1909
+ *
1910
+ */
1911
+ static rotateWebhookSecret(options) {
1912
+ return (options.client ?? client).post({
1913
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}:rotate-secret",
1914
+ ...options
1915
+ });
1916
+ }
1917
+ /**
1918
+ * List webhook deliveries
1919
+ *
1920
+ * Every delivery attempted in the project, newest first — what was sent, where, how many times, and what came back. Filter by endpoint, by lifecycle status, or by event type.
1921
+ * Deliveries are per (event, endpoint): an event matching two subscribed endpoints produces two rows, retried and observed independently.
1922
+ *
1923
+ */
1924
+ static listWebhookDeliveries(options) {
1925
+ return (options.client ?? client).get({
1926
+ url: "/v1/projects/{project_id}/webhook-deliveries",
1927
+ ...options
1928
+ });
1929
+ }
1930
+ /**
1931
+ * Get a webhook delivery
1932
+ *
1933
+ * One delivery, including the exact payload that was signed and sent.
1934
+ *
1935
+ */
1936
+ static getWebhookDelivery(options) {
1937
+ return (options.client ?? client).get({
1938
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}",
1939
+ ...options
1940
+ });
1941
+ }
1942
+ /**
1943
+ * Redeliver an event
1944
+ *
1945
+ * Queue the same event at the same endpoint again — the recovery path for a delivery that failed, or one your receiver dropped. This is the `…:redeliver` action; the path segment is `{delivery_id}:redeliver`.
1946
+ * A **new** delivery is created and returned; the original record is left untouched, because its attempt history is the evidence you redelivered on. The event's `id` is carried over unchanged, so a receiver deduping on the event sees the same event twice while one deduping on `X-Naturali-Delivery` sees a distinct delivery.
1947
+ *
1948
+ */
1949
+ static redeliverWebhookDelivery(options) {
1950
+ return (options.client ?? client).post({
1951
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}:redeliver",
1952
+ ...options
1953
+ });
1954
+ }
1955
+ };
1836
1956
  //#endregion
1837
1957
  //#region src/naturaliClient.ts
1838
1958
  /**
@@ -1895,6 +2015,7 @@ var NaturaliClient = class {
1895
2015
  tasks;
1896
2016
  tools;
1897
2017
  traces;
2018
+ webhooks;
1898
2019
  /** The underlying HTTP client, for interceptors or one-off requests. */
1899
2020
  http;
1900
2021
  constructor({ token, headers } = {}) {
@@ -1920,6 +2041,7 @@ var NaturaliClient = class {
1920
2041
  this.tasks = bindResource(Tasks, this.http);
1921
2042
  this.tools = bindResource(Tools, this.http);
1922
2043
  this.traces = bindResource(Traces, this.http);
2044
+ this.webhooks = bindResource(Webhooks, this.http);
1923
2045
  }
1924
2046
  };
1925
2047
  //#endregion
@@ -1939,5 +2061,6 @@ exports.Sessions = Sessions;
1939
2061
  exports.Tasks = Tasks;
1940
2062
  exports.Tools = Tools;
1941
2063
  exports.Traces = Traces;
2064
+ exports.Webhooks = Webhooks;
1942
2065
  exports.createClient = createClient;
1943
2066
  exports.createConfig = createConfig;