@lifestreamdynamics/vault-sdk 1.0.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1121 -0
  3. package/dist/client.d.ts +143 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +286 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/errors.d.ts +28 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +49 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/handle-error.d.ts +8 -0
  12. package/dist/handle-error.d.ts.map +1 -0
  13. package/dist/handle-error.js +35 -0
  14. package/dist/handle-error.js.map +1 -0
  15. package/dist/index.d.ts +32 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +26 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/lib/audit-logger.d.ts +29 -0
  20. package/dist/lib/audit-logger.d.ts.map +1 -0
  21. package/dist/lib/audit-logger.js +99 -0
  22. package/dist/lib/audit-logger.js.map +1 -0
  23. package/dist/lib/encryption.d.ts +34 -0
  24. package/dist/lib/encryption.d.ts.map +1 -0
  25. package/dist/lib/encryption.js +87 -0
  26. package/dist/lib/encryption.js.map +1 -0
  27. package/dist/lib/signature.d.ts +47 -0
  28. package/dist/lib/signature.d.ts.map +1 -0
  29. package/dist/lib/signature.js +71 -0
  30. package/dist/lib/signature.js.map +1 -0
  31. package/dist/lib/token-manager.d.ts +80 -0
  32. package/dist/lib/token-manager.d.ts.map +1 -0
  33. package/dist/lib/token-manager.js +116 -0
  34. package/dist/lib/token-manager.js.map +1 -0
  35. package/dist/resources/admin.d.ts +280 -0
  36. package/dist/resources/admin.d.ts.map +1 -0
  37. package/dist/resources/admin.js +236 -0
  38. package/dist/resources/admin.js.map +1 -0
  39. package/dist/resources/ai.d.ts +184 -0
  40. package/dist/resources/ai.d.ts.map +1 -0
  41. package/dist/resources/ai.js +179 -0
  42. package/dist/resources/ai.js.map +1 -0
  43. package/dist/resources/api-keys.d.ts +172 -0
  44. package/dist/resources/api-keys.d.ts.map +1 -0
  45. package/dist/resources/api-keys.js +166 -0
  46. package/dist/resources/api-keys.js.map +1 -0
  47. package/dist/resources/connectors.d.ts +263 -0
  48. package/dist/resources/connectors.d.ts.map +1 -0
  49. package/dist/resources/connectors.js +226 -0
  50. package/dist/resources/connectors.js.map +1 -0
  51. package/dist/resources/documents.d.ts +334 -0
  52. package/dist/resources/documents.d.ts.map +1 -0
  53. package/dist/resources/documents.js +377 -0
  54. package/dist/resources/documents.js.map +1 -0
  55. package/dist/resources/hooks.d.ts +195 -0
  56. package/dist/resources/hooks.d.ts.map +1 -0
  57. package/dist/resources/hooks.js +166 -0
  58. package/dist/resources/hooks.js.map +1 -0
  59. package/dist/resources/publish.d.ts +165 -0
  60. package/dist/resources/publish.d.ts.map +1 -0
  61. package/dist/resources/publish.js +150 -0
  62. package/dist/resources/publish.js.map +1 -0
  63. package/dist/resources/search.d.ts +94 -0
  64. package/dist/resources/search.d.ts.map +1 -0
  65. package/dist/resources/search.js +76 -0
  66. package/dist/resources/search.js.map +1 -0
  67. package/dist/resources/shares.d.ts +130 -0
  68. package/dist/resources/shares.d.ts.map +1 -0
  69. package/dist/resources/shares.js +115 -0
  70. package/dist/resources/shares.js.map +1 -0
  71. package/dist/resources/subscription.d.ts +172 -0
  72. package/dist/resources/subscription.d.ts.map +1 -0
  73. package/dist/resources/subscription.js +166 -0
  74. package/dist/resources/subscription.js.map +1 -0
  75. package/dist/resources/teams.d.ts +356 -0
  76. package/dist/resources/teams.d.ts.map +1 -0
  77. package/dist/resources/teams.js +395 -0
  78. package/dist/resources/teams.js.map +1 -0
  79. package/dist/resources/user.d.ts +92 -0
  80. package/dist/resources/user.d.ts.map +1 -0
  81. package/dist/resources/user.js +64 -0
  82. package/dist/resources/user.js.map +1 -0
  83. package/dist/resources/vaults.d.ts +144 -0
  84. package/dist/resources/vaults.d.ts.map +1 -0
  85. package/dist/resources/vaults.js +158 -0
  86. package/dist/resources/vaults.js.map +1 -0
  87. package/dist/resources/webhooks.d.ts +187 -0
  88. package/dist/resources/webhooks.d.ts.map +1 -0
  89. package/dist/resources/webhooks.js +171 -0
  90. package/dist/resources/webhooks.js.map +1 -0
  91. package/dist/types/api.d.ts +17 -0
  92. package/dist/types/api.d.ts.map +1 -0
  93. package/dist/types/api.js +2 -0
  94. package/dist/types/api.js.map +1 -0
  95. package/dist/types/index.d.ts +3 -0
  96. package/dist/types/index.d.ts.map +1 -0
  97. package/dist/types/index.js +2 -0
  98. package/dist/types/index.js.map +1 -0
  99. package/dist/types/resources.d.ts +5 -0
  100. package/dist/types/resources.d.ts.map +1 -0
  101. package/dist/types/resources.js +2 -0
  102. package/dist/types/resources.js.map +1 -0
  103. package/package.json +58 -0
@@ -0,0 +1,144 @@
1
+ import type { KyInstance } from 'ky';
2
+ /** A vault object returned by the API. */
3
+ export interface Vault {
4
+ /** Unique vault identifier. */
5
+ id: string;
6
+ /** Display name of the vault. */
7
+ name: string;
8
+ /** URL-friendly slug, unique per user. */
9
+ slug: string;
10
+ /** Optional vault description. */
11
+ description: string | null;
12
+ /** Whether client-side encryption is enabled for this vault. */
13
+ encryptionEnabled: boolean;
14
+ /** ISO 8601 creation timestamp. */
15
+ createdAt: string;
16
+ /** ISO 8601 last-updated timestamp. */
17
+ updatedAt: string;
18
+ }
19
+ /**
20
+ * Resource for managing vaults.
21
+ *
22
+ * Vaults are isolated document storage containers. Each vault has a unique
23
+ * slug and can hold an arbitrary number of Markdown documents organized
24
+ * in a directory structure.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const vaults = await client.vaults.list();
29
+ * const vault = await client.vaults.create({ name: 'My Notes' });
30
+ * ```
31
+ */
32
+ export declare class VaultsResource {
33
+ private http;
34
+ constructor(http: KyInstance);
35
+ /**
36
+ * Lists all vaults accessible to the authenticated user.
37
+ *
38
+ * @returns Array of vault objects
39
+ * @throws {AuthenticationError} If the request is not authenticated
40
+ * @throws {NetworkError} If the request fails due to network issues
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const vaults = await client.vaults.list();
45
+ * for (const vault of vaults) {
46
+ * console.log(vault.name, vault.slug);
47
+ * }
48
+ * ```
49
+ */
50
+ list(): Promise<Vault[]>;
51
+ /**
52
+ * Retrieves a single vault by ID.
53
+ *
54
+ * @param vaultId - The unique identifier of the vault
55
+ * @returns The vault object
56
+ * @throws {NotFoundError} If no vault exists with the given ID
57
+ * @throws {AuthenticationError} If the request is not authenticated
58
+ * @throws {NetworkError} If the request fails due to network issues
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const vault = await client.vaults.get('vault-uuid');
63
+ * console.log(vault.name);
64
+ * ```
65
+ */
66
+ get(vaultId: string): Promise<Vault>;
67
+ /**
68
+ * Creates a new vault.
69
+ *
70
+ * A URL-friendly slug is automatically generated from the vault name.
71
+ *
72
+ * @param params - Vault creation parameters
73
+ * @param params.name - Display name for the vault (required)
74
+ * @param params.description - Optional description of the vault's purpose
75
+ * @returns The newly created vault object
76
+ * @throws {ValidationError} If the name is empty or the generated slug conflicts with an existing vault
77
+ * @throws {AuthenticationError} If the request is not authenticated
78
+ * @throws {NetworkError} If the request fails due to network issues
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const vault = await client.vaults.create({
83
+ * name: 'Work Documents',
84
+ * description: 'Team documentation and notes',
85
+ * });
86
+ * console.log(vault.id, vault.slug);
87
+ * ```
88
+ *
89
+ * @see {@link VaultsResource.update} to modify an existing vault
90
+ */
91
+ create(params: {
92
+ name: string;
93
+ description?: string;
94
+ encryptionEnabled?: boolean;
95
+ }): Promise<Vault>;
96
+ /**
97
+ * Updates an existing vault's metadata.
98
+ *
99
+ * Only the provided fields are modified; omitted fields remain unchanged.
100
+ * Set `description` to `null` to clear it.
101
+ *
102
+ * @param vaultId - The unique identifier of the vault to update
103
+ * @param params - Fields to update
104
+ * @param params.name - New display name for the vault
105
+ * @param params.description - New description, or `null` to clear
106
+ * @returns The updated vault object
107
+ * @throws {NotFoundError} If no vault exists with the given ID
108
+ * @throws {ValidationError} If the new name produces a conflicting slug
109
+ * @throws {AuthenticationError} If the request is not authenticated
110
+ * @throws {NetworkError} If the request fails due to network issues
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const updated = await client.vaults.update('vault-uuid', {
115
+ * name: 'Renamed Vault',
116
+ * description: null,
117
+ * });
118
+ * ```
119
+ *
120
+ * @see {@link VaultsResource.create} to create a new vault
121
+ */
122
+ update(vaultId: string, params: {
123
+ name?: string;
124
+ description?: string | null;
125
+ }): Promise<Vault>;
126
+ /**
127
+ * Permanently deletes a vault and all its documents.
128
+ *
129
+ * This action is irreversible. All documents within the vault will be
130
+ * removed from both the filesystem and the database.
131
+ *
132
+ * @param vaultId - The unique identifier of the vault to delete
133
+ * @throws {NotFoundError} If no vault exists with the given ID
134
+ * @throws {AuthenticationError} If the request is not authenticated
135
+ * @throws {NetworkError} If the request fails due to network issues
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * await client.vaults.delete('vault-uuid');
140
+ * ```
141
+ */
142
+ delete(vaultId: string): Promise<void>;
143
+ }
144
+ //# sourceMappingURL=vaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaults.d.ts","sourceRoot":"","sources":["../../src/resources/vaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGrC,0CAA0C;AAC1C,MAAM,WAAW,KAAK;IACpB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gEAAgE;IAChE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;;;;;;;;;OAcG;IACG,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAS9B;;;;;;;;;;;;;;OAcG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ1C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAQzG;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAQrG;;;;;;;;;;;;;;;OAeG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO7C"}
@@ -0,0 +1,158 @@
1
+ import { handleError } from '../handle-error.js';
2
+ /**
3
+ * Resource for managing vaults.
4
+ *
5
+ * Vaults are isolated document storage containers. Each vault has a unique
6
+ * slug and can hold an arbitrary number of Markdown documents organized
7
+ * in a directory structure.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const vaults = await client.vaults.list();
12
+ * const vault = await client.vaults.create({ name: 'My Notes' });
13
+ * ```
14
+ */
15
+ export class VaultsResource {
16
+ http;
17
+ constructor(http) {
18
+ this.http = http;
19
+ }
20
+ /**
21
+ * Lists all vaults accessible to the authenticated user.
22
+ *
23
+ * @returns Array of vault objects
24
+ * @throws {AuthenticationError} If the request is not authenticated
25
+ * @throws {NetworkError} If the request fails due to network issues
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const vaults = await client.vaults.list();
30
+ * for (const vault of vaults) {
31
+ * console.log(vault.name, vault.slug);
32
+ * }
33
+ * ```
34
+ */
35
+ async list() {
36
+ try {
37
+ const data = await this.http.get('vaults').json();
38
+ return data.vaults;
39
+ }
40
+ catch (error) {
41
+ throw await handleError(error, 'Vaults', '');
42
+ }
43
+ }
44
+ /**
45
+ * Retrieves a single vault by ID.
46
+ *
47
+ * @param vaultId - The unique identifier of the vault
48
+ * @returns The vault object
49
+ * @throws {NotFoundError} If no vault exists with the given ID
50
+ * @throws {AuthenticationError} If the request is not authenticated
51
+ * @throws {NetworkError} If the request fails due to network issues
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const vault = await client.vaults.get('vault-uuid');
56
+ * console.log(vault.name);
57
+ * ```
58
+ */
59
+ async get(vaultId) {
60
+ try {
61
+ return await this.http.get(`vaults/${vaultId}`).json();
62
+ }
63
+ catch (error) {
64
+ throw await handleError(error, 'Vault', vaultId);
65
+ }
66
+ }
67
+ /**
68
+ * Creates a new vault.
69
+ *
70
+ * A URL-friendly slug is automatically generated from the vault name.
71
+ *
72
+ * @param params - Vault creation parameters
73
+ * @param params.name - Display name for the vault (required)
74
+ * @param params.description - Optional description of the vault's purpose
75
+ * @returns The newly created vault object
76
+ * @throws {ValidationError} If the name is empty or the generated slug conflicts with an existing vault
77
+ * @throws {AuthenticationError} If the request is not authenticated
78
+ * @throws {NetworkError} If the request fails due to network issues
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const vault = await client.vaults.create({
83
+ * name: 'Work Documents',
84
+ * description: 'Team documentation and notes',
85
+ * });
86
+ * console.log(vault.id, vault.slug);
87
+ * ```
88
+ *
89
+ * @see {@link VaultsResource.update} to modify an existing vault
90
+ */
91
+ async create(params) {
92
+ try {
93
+ return await this.http.post('vaults', { json: params }).json();
94
+ }
95
+ catch (error) {
96
+ throw await handleError(error, 'Vault', params.name);
97
+ }
98
+ }
99
+ /**
100
+ * Updates an existing vault's metadata.
101
+ *
102
+ * Only the provided fields are modified; omitted fields remain unchanged.
103
+ * Set `description` to `null` to clear it.
104
+ *
105
+ * @param vaultId - The unique identifier of the vault to update
106
+ * @param params - Fields to update
107
+ * @param params.name - New display name for the vault
108
+ * @param params.description - New description, or `null` to clear
109
+ * @returns The updated vault object
110
+ * @throws {NotFoundError} If no vault exists with the given ID
111
+ * @throws {ValidationError} If the new name produces a conflicting slug
112
+ * @throws {AuthenticationError} If the request is not authenticated
113
+ * @throws {NetworkError} If the request fails due to network issues
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const updated = await client.vaults.update('vault-uuid', {
118
+ * name: 'Renamed Vault',
119
+ * description: null,
120
+ * });
121
+ * ```
122
+ *
123
+ * @see {@link VaultsResource.create} to create a new vault
124
+ */
125
+ async update(vaultId, params) {
126
+ try {
127
+ return await this.http.put(`vaults/${vaultId}`, { json: params }).json();
128
+ }
129
+ catch (error) {
130
+ throw await handleError(error, 'Vault', vaultId);
131
+ }
132
+ }
133
+ /**
134
+ * Permanently deletes a vault and all its documents.
135
+ *
136
+ * This action is irreversible. All documents within the vault will be
137
+ * removed from both the filesystem and the database.
138
+ *
139
+ * @param vaultId - The unique identifier of the vault to delete
140
+ * @throws {NotFoundError} If no vault exists with the given ID
141
+ * @throws {AuthenticationError} If the request is not authenticated
142
+ * @throws {NetworkError} If the request fails due to network issues
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * await client.vaults.delete('vault-uuid');
147
+ * ```
148
+ */
149
+ async delete(vaultId) {
150
+ try {
151
+ await this.http.delete(`vaults/${vaultId}`);
152
+ }
153
+ catch (error) {
154
+ throw await handleError(error, 'Vault', vaultId);
155
+ }
156
+ }
157
+ }
158
+ //# sourceMappingURL=vaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaults.js","sourceRoot":"","sources":["../../src/resources/vaults.ts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;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,MAAsD;QAClF,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAS,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,187 @@
1
+ import type { KyInstance } from 'ky';
2
+ /** A webhook object returned by the API. */
3
+ export interface Webhook {
4
+ /** Unique webhook identifier. */
5
+ id: string;
6
+ /** Vault this webhook belongs to. */
7
+ vaultId: string;
8
+ /** URL that receives webhook deliveries. */
9
+ url: string;
10
+ /** Event types this webhook subscribes to (e.g., `['create', 'update', 'delete']`). */
11
+ events: string[];
12
+ /** Whether the webhook is currently active. */
13
+ isActive: boolean;
14
+ /** ISO 8601 creation timestamp. */
15
+ createdAt: string;
16
+ /** ISO 8601 last-updated timestamp. */
17
+ updatedAt: string;
18
+ }
19
+ /** A webhook with the signing secret included. Only returned on creation. */
20
+ export interface WebhookWithSecret extends Webhook {
21
+ /** HMAC signing secret for verifying webhook payloads. Only available at creation time. */
22
+ secret: string;
23
+ }
24
+ /** A webhook delivery log entry. */
25
+ export interface WebhookDelivery {
26
+ /** Unique delivery identifier. */
27
+ id: string;
28
+ /** Webhook this delivery belongs to. */
29
+ webhookId: string;
30
+ /** Vault event that triggered the delivery. */
31
+ eventId: string;
32
+ /** HTTP status code returned by the endpoint, or `null` if delivery failed. */
33
+ statusCode: number | null;
34
+ /** Delivery attempt number. */
35
+ attempt: number;
36
+ /** Request body that was sent. */
37
+ requestBody: unknown;
38
+ /** Response body from the endpoint, or `null`. */
39
+ responseBody: string | null;
40
+ /** Error message if delivery failed, or `null`. */
41
+ error: string | null;
42
+ /** ISO 8601 timestamp of successful delivery, or `null`. */
43
+ deliveredAt: string | null;
44
+ /** ISO 8601 creation timestamp. */
45
+ createdAt: string;
46
+ }
47
+ /** Parameters for creating a new webhook. */
48
+ export interface CreateWebhookParams {
49
+ /** URL to receive webhook deliveries. Must be a publicly accessible HTTPS endpoint. */
50
+ url: string;
51
+ /** Event types to subscribe to (e.g., `['create', 'update', 'delete']`). */
52
+ events: string[];
53
+ }
54
+ /** Parameters for updating an existing webhook. */
55
+ export interface UpdateWebhookParams {
56
+ /** New URL for the webhook endpoint. */
57
+ url?: string;
58
+ /** New set of event types to subscribe to. */
59
+ events?: string[];
60
+ /** Whether the webhook should be active. */
61
+ isActive?: boolean;
62
+ }
63
+ /**
64
+ * Resource for managing vault webhooks.
65
+ *
66
+ * Webhooks send HTTP POST notifications to external URLs when document events
67
+ * occur in a vault. Payloads are signed with HMAC-SHA256 for verification.
68
+ *
69
+ * Requires a **pro** or higher subscription tier.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const webhooks = await client.webhooks.list('vault-123');
74
+ * const webhook = await client.webhooks.create('vault-123', {
75
+ * url: 'https://example.com/webhook',
76
+ * events: ['create', 'update'],
77
+ * });
78
+ * console.log('Save this secret:', webhook.secret);
79
+ * ```
80
+ */
81
+ export declare class WebhooksResource {
82
+ private http;
83
+ constructor(http: KyInstance);
84
+ /**
85
+ * Lists all webhooks for a vault.
86
+ *
87
+ * @param vaultId - The vault to list webhooks for
88
+ * @returns Array of webhook objects (without secrets)
89
+ * @throws {AuthenticationError} If not authenticated
90
+ * @throws {AuthorizationError} If the user lacks access to the vault
91
+ * @throws {NetworkError} If the request fails due to network issues
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const webhooks = await client.webhooks.list('vault-123');
96
+ * for (const wh of webhooks) {
97
+ * console.log(wh.url, wh.events, wh.isActive);
98
+ * }
99
+ * ```
100
+ */
101
+ list(vaultId: string): Promise<Webhook[]>;
102
+ /**
103
+ * Creates a new webhook in a vault.
104
+ *
105
+ * The signing secret is only returned on creation. Store it securely --
106
+ * it cannot be retrieved later. Use it to verify HMAC-SHA256 signatures
107
+ * on incoming webhook payloads.
108
+ *
109
+ * @param vaultId - The vault to create the webhook in
110
+ * @param params - Webhook creation parameters
111
+ * @returns The created webhook object including the signing secret
112
+ * @throws {ValidationError} If parameters are invalid or the URL is blocked (SSRF protection)
113
+ * @throws {AuthenticationError} If not authenticated
114
+ * @throws {AuthorizationError} If the user lacks access to the vault
115
+ * @throws {NetworkError} If the request fails due to network issues
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const webhook = await client.webhooks.create('vault-123', {
120
+ * url: 'https://example.com/webhook',
121
+ * events: ['create', 'update', 'delete'],
122
+ * });
123
+ * console.log('Save this secret:', webhook.secret);
124
+ * ```
125
+ */
126
+ create(vaultId: string, params: CreateWebhookParams): Promise<WebhookWithSecret>;
127
+ /**
128
+ * Updates an existing webhook.
129
+ *
130
+ * Only the provided fields are modified; omitted fields remain unchanged.
131
+ *
132
+ * @param vaultId - The vault the webhook belongs to
133
+ * @param webhookId - The webhook to update
134
+ * @param params - Fields to update
135
+ * @returns The updated webhook object
136
+ * @throws {ValidationError} If parameters are invalid or the URL is blocked
137
+ * @throws {NotFoundError} If the webhook does not exist in the vault
138
+ * @throws {AuthenticationError} If not authenticated
139
+ * @throws {NetworkError} If the request fails due to network issues
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const updated = await client.webhooks.update('vault-123', 'wh-456', {
144
+ * events: ['create', 'delete'],
145
+ * isActive: false,
146
+ * });
147
+ * ```
148
+ */
149
+ update(vaultId: string, webhookId: string, params: UpdateWebhookParams): Promise<Webhook>;
150
+ /**
151
+ * Deletes a webhook permanently.
152
+ *
153
+ * @param vaultId - The vault the webhook belongs to
154
+ * @param webhookId - The webhook to delete
155
+ * @throws {NotFoundError} If the webhook does not exist in the vault
156
+ * @throws {AuthenticationError} If not authenticated
157
+ * @throws {NetworkError} If the request fails due to network issues
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * await client.webhooks.delete('vault-123', 'wh-456');
162
+ * ```
163
+ */
164
+ delete(vaultId: string, webhookId: string): Promise<void>;
165
+ /**
166
+ * Lists recent deliveries for a webhook.
167
+ *
168
+ * Returns up to 50 most recent delivery log entries, ordered by most recent first.
169
+ *
170
+ * @param vaultId - The vault the webhook belongs to
171
+ * @param webhookId - The webhook to get deliveries for
172
+ * @returns Array of webhook delivery log entries
173
+ * @throws {NotFoundError} If the webhook does not exist in the vault
174
+ * @throws {AuthenticationError} If not authenticated
175
+ * @throws {NetworkError} If the request fails due to network issues
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const deliveries = await client.webhooks.listDeliveries('vault-123', 'wh-456');
180
+ * for (const d of deliveries) {
181
+ * console.log(d.statusCode, d.attempt, d.deliveredAt);
182
+ * }
183
+ * ```
184
+ */
185
+ listDeliveries(vaultId: string, webhookId: string): Promise<WebhookDelivery[]>;
186
+ }
187
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGrC,4CAA4C;AAC5C,MAAM,WAAW,OAAO;IACtB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,GAAG,E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;GAiBG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAS/C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUtF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAU/F;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D;;;;;;;;;;;;;;;;;;;OAmBG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAUrF"}
@@ -0,0 +1,171 @@
1
+ import { handleError } from '../handle-error.js';
2
+ /**
3
+ * Resource for managing vault webhooks.
4
+ *
5
+ * Webhooks send HTTP POST notifications to external URLs when document events
6
+ * occur in a vault. Payloads are signed with HMAC-SHA256 for verification.
7
+ *
8
+ * Requires a **pro** or higher subscription tier.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const webhooks = await client.webhooks.list('vault-123');
13
+ * const webhook = await client.webhooks.create('vault-123', {
14
+ * url: 'https://example.com/webhook',
15
+ * events: ['create', 'update'],
16
+ * });
17
+ * console.log('Save this secret:', webhook.secret);
18
+ * ```
19
+ */
20
+ export class WebhooksResource {
21
+ http;
22
+ constructor(http) {
23
+ this.http = http;
24
+ }
25
+ /**
26
+ * Lists all webhooks for a vault.
27
+ *
28
+ * @param vaultId - The vault to list webhooks for
29
+ * @returns Array of webhook objects (without secrets)
30
+ * @throws {AuthenticationError} If not authenticated
31
+ * @throws {AuthorizationError} If the user lacks access to the vault
32
+ * @throws {NetworkError} If the request fails due to network issues
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const webhooks = await client.webhooks.list('vault-123');
37
+ * for (const wh of webhooks) {
38
+ * console.log(wh.url, wh.events, wh.isActive);
39
+ * }
40
+ * ```
41
+ */
42
+ async list(vaultId) {
43
+ try {
44
+ const data = await this.http.get(`vaults/${vaultId}/webhooks`).json();
45
+ return data.webhooks;
46
+ }
47
+ catch (error) {
48
+ throw await handleError(error, 'Webhooks', vaultId);
49
+ }
50
+ }
51
+ /**
52
+ * Creates a new webhook in a vault.
53
+ *
54
+ * The signing secret is only returned on creation. Store it securely --
55
+ * it cannot be retrieved later. Use it to verify HMAC-SHA256 signatures
56
+ * on incoming webhook payloads.
57
+ *
58
+ * @param vaultId - The vault to create the webhook in
59
+ * @param params - Webhook creation parameters
60
+ * @returns The created webhook object including the signing secret
61
+ * @throws {ValidationError} If parameters are invalid or the URL is blocked (SSRF protection)
62
+ * @throws {AuthenticationError} If not authenticated
63
+ * @throws {AuthorizationError} If the user lacks access to the vault
64
+ * @throws {NetworkError} If the request fails due to network issues
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const webhook = await client.webhooks.create('vault-123', {
69
+ * url: 'https://example.com/webhook',
70
+ * events: ['create', 'update', 'delete'],
71
+ * });
72
+ * console.log('Save this secret:', webhook.secret);
73
+ * ```
74
+ */
75
+ async create(vaultId, params) {
76
+ try {
77
+ return await this.http
78
+ .post(`vaults/${vaultId}/webhooks`, { json: params })
79
+ .json();
80
+ }
81
+ catch (error) {
82
+ throw await handleError(error, 'Webhook', params.url);
83
+ }
84
+ }
85
+ /**
86
+ * Updates an existing webhook.
87
+ *
88
+ * Only the provided fields are modified; omitted fields remain unchanged.
89
+ *
90
+ * @param vaultId - The vault the webhook belongs to
91
+ * @param webhookId - The webhook to update
92
+ * @param params - Fields to update
93
+ * @returns The updated webhook object
94
+ * @throws {ValidationError} If parameters are invalid or the URL is blocked
95
+ * @throws {NotFoundError} If the webhook does not exist in the vault
96
+ * @throws {AuthenticationError} If not authenticated
97
+ * @throws {NetworkError} If the request fails due to network issues
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const updated = await client.webhooks.update('vault-123', 'wh-456', {
102
+ * events: ['create', 'delete'],
103
+ * isActive: false,
104
+ * });
105
+ * ```
106
+ */
107
+ async update(vaultId, webhookId, params) {
108
+ try {
109
+ return await this.http
110
+ .put(`vaults/${vaultId}/webhooks/${webhookId}`, { json: params })
111
+ .json();
112
+ }
113
+ catch (error) {
114
+ throw await handleError(error, 'Webhook', webhookId);
115
+ }
116
+ }
117
+ /**
118
+ * Deletes a webhook permanently.
119
+ *
120
+ * @param vaultId - The vault the webhook belongs to
121
+ * @param webhookId - The webhook to delete
122
+ * @throws {NotFoundError} If the webhook does not exist in the vault
123
+ * @throws {AuthenticationError} If not authenticated
124
+ * @throws {NetworkError} If the request fails due to network issues
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * await client.webhooks.delete('vault-123', 'wh-456');
129
+ * ```
130
+ */
131
+ async delete(vaultId, webhookId) {
132
+ try {
133
+ await this.http.delete(`vaults/${vaultId}/webhooks/${webhookId}`);
134
+ }
135
+ catch (error) {
136
+ throw await handleError(error, 'Webhook', webhookId);
137
+ }
138
+ }
139
+ /**
140
+ * Lists recent deliveries for a webhook.
141
+ *
142
+ * Returns up to 50 most recent delivery log entries, ordered by most recent first.
143
+ *
144
+ * @param vaultId - The vault the webhook belongs to
145
+ * @param webhookId - The webhook to get deliveries for
146
+ * @returns Array of webhook delivery log entries
147
+ * @throws {NotFoundError} If the webhook does not exist in the vault
148
+ * @throws {AuthenticationError} If not authenticated
149
+ * @throws {NetworkError} If the request fails due to network issues
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const deliveries = await client.webhooks.listDeliveries('vault-123', 'wh-456');
154
+ * for (const d of deliveries) {
155
+ * console.log(d.statusCode, d.attempt, d.deliveredAt);
156
+ * }
157
+ * ```
158
+ */
159
+ async listDeliveries(vaultId, webhookId) {
160
+ try {
161
+ const data = await this.http
162
+ .get(`vaults/${vaultId}/webhooks/${webhookId}/deliveries`)
163
+ .json();
164
+ return data.deliveries;
165
+ }
166
+ catch (error) {
167
+ throw await handleError(error, 'Webhook', webhookId);
168
+ }
169
+ }
170
+ }
171
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAI,CAAC,OAAe;QACxB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,OAAO,WAAW,CAAC,CAAC,IAAI,EAA2B,CAAC;YAC/F,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,MAA2B;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI;iBACnB,IAAI,CAAC,UAAU,OAAO,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iBACpD,IAAI,EAAqB,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,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