@verbatims/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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -0
  3. package/dist/client.d.ts +35 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +156 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/errors.d.ts +26 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +51 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +22 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +27 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/pagination.d.ts +9 -0
  16. package/dist/pagination.d.ts.map +1 -0
  17. package/dist/pagination.js +16 -0
  18. package/dist/pagination.js.map +1 -0
  19. package/dist/resources/authors.d.ts +145 -0
  20. package/dist/resources/authors.d.ts.map +1 -0
  21. package/dist/resources/authors.js +48 -0
  22. package/dist/resources/authors.js.map +1 -0
  23. package/dist/resources/collections.d.ts +57 -0
  24. package/dist/resources/collections.d.ts.map +1 -0
  25. package/dist/resources/collections.js +32 -0
  26. package/dist/resources/collections.js.map +1 -0
  27. package/dist/resources/index.d.ts +7 -0
  28. package/dist/resources/index.d.ts.map +1 -0
  29. package/dist/resources/index.js +7 -0
  30. package/dist/resources/index.js.map +1 -0
  31. package/dist/resources/quotes.d.ts +226 -0
  32. package/dist/resources/quotes.d.ts.map +1 -0
  33. package/dist/resources/quotes.js +69 -0
  34. package/dist/resources/quotes.js.map +1 -0
  35. package/dist/resources/references.d.ts +135 -0
  36. package/dist/resources/references.d.ts.map +1 -0
  37. package/dist/resources/references.js +46 -0
  38. package/dist/resources/references.js.map +1 -0
  39. package/dist/resources/search.d.ts +36 -0
  40. package/dist/resources/search.d.ts.map +1 -0
  41. package/dist/resources/search.js +27 -0
  42. package/dist/resources/search.js.map +1 -0
  43. package/dist/resources/tags.d.ts +39 -0
  44. package/dist/resources/tags.d.ts.map +1 -0
  45. package/dist/resources/tags.js +26 -0
  46. package/dist/resources/tags.js.map +1 -0
  47. package/dist/types.d.ts +203 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +23 -0
  50. package/dist/types.js.map +1 -0
  51. package/nuxt/composables.ts +31 -0
  52. package/nuxt/module.ts +31 -0
  53. package/package.json +85 -0
  54. package/src/__tests__/client.test.ts +304 -0
  55. package/src/__tests__/errors.test.ts +85 -0
  56. package/src/__tests__/pagination.test.ts +100 -0
  57. package/src/client.ts +213 -0
  58. package/src/errors.ts +54 -0
  59. package/src/index.ts +58 -0
  60. package/src/pagination.ts +25 -0
  61. package/src/resources/__tests__/resources.test.ts +386 -0
  62. package/src/resources/authors.ts +58 -0
  63. package/src/resources/collections.ts +45 -0
  64. package/src/resources/index.ts +6 -0
  65. package/src/resources/quotes.ts +80 -0
  66. package/src/resources/references.ts +56 -0
  67. package/src/resources/search.ts +34 -0
  68. package/src/resources/tags.ts +32 -0
  69. package/src/types.ts +221 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Verbatims
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @verbatims/sdk
2
+
3
+ TypeScript SDK for the [Verbatims](https://verbatims.cc) quotes API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @verbatims/sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { VerbatimsClient } from '@verbatims/sdk'
15
+
16
+ const vb = new VerbatimsClient('vbt_your_api_key')
17
+
18
+ // List quotes
19
+ const { data } = await vb.quotes.list({ language: 'fr', limit: 10 })
20
+
21
+ // Get a single quote
22
+ const quote = await vb.quotes.get(42)
23
+
24
+ // Create a quote
25
+ const created = await vb.quotes.create({
26
+ name: 'Life is what happens when you\'re busy making other plans.',
27
+ author_id: 1,
28
+ language: 'en',
29
+ })
30
+
31
+ // Iterate through all pages
32
+ for await (const quote of vb.quotes.paginate({ language: 'fr' })) {
33
+ console.log(quote.id, quote.name)
34
+ }
35
+ ```
36
+
37
+ ## Resources
38
+
39
+ | Resource | Methods |
40
+ |---|---|
41
+ | `vb.quotes` | `list`, `get`, `create`, `update`, `delete`, `paginate` |
42
+ | `vb.authors` | `list`, `get`, `create`, `update`, `paginate` |
43
+ | `vb.references` | `list`, `get`, `create`, `update`, `paginate` |
44
+ | `vb.tags` | `list`, `paginate` |
45
+ | `vb.collections` | `create`, `addQuote`, `removeQuote` |
46
+ | `vb.search` | `query`, `paginate` |
47
+
48
+ ## Nuxt module
49
+
50
+ ```ts
51
+ // nuxt.config.ts
52
+ export default defineNuxtConfig({
53
+ modules: ['@verbatims/sdk/nuxt/module'],
54
+ })
55
+ ```
56
+
57
+ Composables `useVerbatimsClient`, `useQuotes`, `useSearchQuotes` are auto-imported.
58
+
59
+ ## License
60
+
61
+ MIT
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod/v4';
2
+ export interface ClientOptions {
3
+ baseUrl?: string;
4
+ timeout?: number;
5
+ retry?: RetryConfig;
6
+ fetch?: typeof globalThis.fetch;
7
+ }
8
+ export interface RetryConfig {
9
+ maxRetries: number;
10
+ baseDelayMs: number;
11
+ }
12
+ interface RequestOptions {
13
+ method?: string;
14
+ body?: unknown;
15
+ params?: Record<string, unknown>;
16
+ signal?: AbortSignal;
17
+ }
18
+ export declare class VerbatimsClient {
19
+ private baseUrl;
20
+ private apiKey;
21
+ private timeout;
22
+ private retry;
23
+ private fetchFn;
24
+ constructor(apiKey: string, opts?: ClientOptions);
25
+ private buildUrl;
26
+ private request;
27
+ private parseRateLimitHeaders;
28
+ private handleError;
29
+ get<T>(path: string, opts?: RequestOptions, schema?: z.ZodType<T>): Promise<T>;
30
+ post<T>(path: string, body: unknown, opts?: RequestOptions, schema?: z.ZodType<T>): Promise<T>;
31
+ put<T>(path: string, body: unknown, opts?: RequestOptions, schema?: z.ZodType<T>): Promise<T>;
32
+ delete<T>(path: string, opts?: RequestOptions, schema?: z.ZodType<T>): Promise<T>;
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB;AAOD,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;I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@
1
+ import { z } from 'zod/v4';
2
+ import { errorResponseSchema } from './types';
3
+ import { VerbatimsError, NotFoundError, RateLimitError, ValidationError, AuthError, ForbiddenError } from './errors';
4
+ const defaultRetry = {
5
+ maxRetries: 3,
6
+ baseDelayMs: 500,
7
+ };
8
+ export class VerbatimsClient {
9
+ baseUrl;
10
+ apiKey;
11
+ timeout;
12
+ retry;
13
+ fetchFn;
14
+ constructor(apiKey, opts = {}) {
15
+ this.apiKey = apiKey;
16
+ this.baseUrl = opts.baseUrl ?? '/api/v1';
17
+ this.timeout = opts.timeout ?? 15_000;
18
+ this.retry = opts.retry ?? defaultRetry;
19
+ this.fetchFn = opts.fetch ?? globalThis.fetch;
20
+ }
21
+ buildUrl(path, params) {
22
+ const url = new URL(`${this.baseUrl}${path}`, 'http://localhost');
23
+ if (params) {
24
+ for (const [key, value] of Object.entries(params)) {
25
+ if (value !== undefined && value !== null) {
26
+ url.searchParams.set(key, String(value));
27
+ }
28
+ }
29
+ }
30
+ return url.pathname + url.search;
31
+ }
32
+ async request(path, opts = {}, schema) {
33
+ const url = this.buildUrl(path, opts.params);
34
+ const method = opts.method ?? 'GET';
35
+ const body = opts.body ? JSON.stringify(opts.body) : undefined;
36
+ let lastError = null;
37
+ const maxRetries = method === 'GET' ? this.retry.maxRetries : 1;
38
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
39
+ try {
40
+ const controller = new AbortController();
41
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
42
+ const signal = opts.signal
43
+ ? anySignal([opts.signal, controller.signal])
44
+ : controller.signal;
45
+ const response = await this.fetchFn(url, {
46
+ method,
47
+ headers: {
48
+ 'Authorization': `Bearer ${this.apiKey}`,
49
+ 'Content-Type': body ? 'application/json' : undefined,
50
+ 'Accept': 'application/json',
51
+ },
52
+ body,
53
+ signal,
54
+ });
55
+ clearTimeout(timeoutId);
56
+ const rateLimitHeaders = this.parseRateLimitHeaders(response.headers);
57
+ const text = await response.text();
58
+ let json;
59
+ try {
60
+ json = JSON.parse(text);
61
+ }
62
+ catch {
63
+ throw new VerbatimsError(`Invalid JSON response: ${text.slice(0, 200)}`, response.status);
64
+ }
65
+ if (!response.ok) {
66
+ this.handleError(response.status, json, rateLimitHeaders);
67
+ }
68
+ const parsed = schema.parse(json);
69
+ return parsed;
70
+ }
71
+ catch (err) {
72
+ lastError = err instanceof Error ? err : new Error(String(err));
73
+ if (err instanceof VerbatimsError) {
74
+ if (err.statusCode === 429 && attempt < maxRetries) {
75
+ const retryAfter = err instanceof RateLimitError ? err.retryAfter : 1;
76
+ await sleep(retryAfter * 1000);
77
+ continue;
78
+ }
79
+ throw err;
80
+ }
81
+ if (attempt < maxRetries && isRetryableError(lastError)) {
82
+ const delay = this.retry.baseDelayMs * Math.pow(2, attempt);
83
+ await sleep(delay);
84
+ continue;
85
+ }
86
+ throw lastError;
87
+ }
88
+ }
89
+ throw lastError ?? new VerbatimsError('Request failed', 0);
90
+ }
91
+ parseRateLimitHeaders(headers) {
92
+ const limit = headers.get('x-ratelimit-limit');
93
+ const remaining = headers.get('x-ratelimit-remaining');
94
+ const reset = headers.get('x-ratelimit-reset');
95
+ if (limit && remaining && reset) {
96
+ return {
97
+ limit: Number(limit),
98
+ remaining: Number(remaining),
99
+ reset: Number(reset),
100
+ };
101
+ }
102
+ return null;
103
+ }
104
+ handleError(status, json, rateLimit) {
105
+ const parsed = errorResponseSchema.safeParse(json);
106
+ const message = parsed.data?.message ?? `HTTP ${status}`;
107
+ const errors = parsed.data?.errors;
108
+ switch (status) {
109
+ case 400:
110
+ throw new ValidationError(message, errors);
111
+ case 401:
112
+ throw new AuthError(message);
113
+ case 403:
114
+ throw new ForbiddenError(message);
115
+ case 404:
116
+ throw new NotFoundError(message);
117
+ case 429:
118
+ throw new RateLimitError(message, rateLimit?.reset ? rateLimit.reset - Math.floor(Date.now() / 1000) : 1, rateLimit?.limit ?? 0, rateLimit?.remaining ?? 0, rateLimit?.reset ?? 0);
119
+ default:
120
+ throw new VerbatimsError(message, status);
121
+ }
122
+ }
123
+ // --- HTTP helpers ---
124
+ async get(path, opts, schema) {
125
+ return this.request(path, { ...opts, method: 'GET' }, schema ?? z.unknown());
126
+ }
127
+ async post(path, body, opts, schema) {
128
+ return this.request(path, { ...opts, method: 'POST', body }, schema ?? z.unknown());
129
+ }
130
+ async put(path, body, opts, schema) {
131
+ return this.request(path, { ...opts, method: 'PUT', body }, schema ?? z.unknown());
132
+ }
133
+ async delete(path, opts, schema) {
134
+ return this.request(path, { ...opts, method: 'DELETE' }, schema ?? z.unknown());
135
+ }
136
+ }
137
+ function anySignal(signals) {
138
+ const controller = new AbortController();
139
+ for (const signal of signals) {
140
+ if (signal.aborted) {
141
+ controller.abort(signal.reason);
142
+ return controller.signal;
143
+ }
144
+ signal.addEventListener('abort', () => controller.abort(signal.reason), { once: true });
145
+ }
146
+ return controller.signal;
147
+ }
148
+ function sleep(ms) {
149
+ return new Promise(resolve => setTimeout(resolve, ms));
150
+ }
151
+ function isRetryableError(err) {
152
+ if (err instanceof VerbatimsError)
153
+ return false;
154
+ return err.name === 'AbortError' || err.message.includes('network') || err.message.includes('fetch');
155
+ }
156
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,mBAAmB,EAA2C,MAAM,SAAS,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAcpH,MAAM,YAAY,GAAgB;IAChC,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,GAAG;CACjB,CAAA;AASD,MAAM,OAAO,eAAe;IAClB,OAAO,CAAQ;IACf,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,KAAK,CAAa;IAClB,OAAO,CAAyB;IAExC,YAAY,M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AAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC,OAAO,EAAkB,CAAC,CAAA;IACjG,CAAC;CACF;AAED,SAAS,SAAS,CAAC,OAAsB;IACvC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAC/B,OAAO,UAAU,CAAC,MAAM,CAAA;QAC1B,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACzF,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,CAAA;AAC1B,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAU;IAClC,IAAI,GAAG,YAAY,cAAc;QAAE,OAAO,KAAK,CAAA;IAC/C,OAAO,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AACtG,CAAC"}
@@ -0,0 +1,26 @@
1
+ export declare class VerbatimsError extends Error {
2
+ statusCode: number;
3
+ code?: string | undefined;
4
+ constructor(message: string, statusCode: number, code?: string | undefined);
5
+ }
6
+ export declare class NotFoundError extends VerbatimsError {
7
+ constructor(message?: string);
8
+ }
9
+ export declare class RateLimitError extends VerbatimsError {
10
+ retryAfter: number;
11
+ limit: number;
12
+ remaining: number;
13
+ reset: number;
14
+ constructor(message: string, retryAfter: number, limit: number, remaining: number, reset: number);
15
+ }
16
+ export declare class ValidationError extends VerbatimsError {
17
+ errors?: string[] | undefined;
18
+ constructor(message: string, errors?: string[] | undefined);
19
+ }
20
+ export declare class AuthError extends VerbatimsError {
21
+ constructor(message?: string);
22
+ }
23
+ export declare class ForbiddenError extends VerbatimsError {
24
+ constructor(message?: string);
25
+ }
26
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IAG9B,UAAU,EAAE,MAAM;IAClB,IAAI,CAAC,EAAE,MAAM;gBAFpB,OAAO,EAAE,MAAM,EACR,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,SAAuB;CAI3C;AAED,qBAAa,cAAe,SAAQ,cAAc;IAGvC,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,MAAM;IACjB,KAAK,EAAE,MAAM;gBAJpB,OAAO,EAAE,MAAM,EACR,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM;CAKvB;AAED,qBAAa,eAAgB,SAAQ,cAAc;IAGxC,MAAM,CAAC,EAAE,MAAM,EAAE;gBADxB,OAAO,EAAE,MAAM,EACR,MAAM,CAAC,EAAE,MAAM,EAAE,YAAA;CAK3B;AAED,qBAAa,SAAU,SAAQ,cAAc;gBAC/B,OAAO,SAA4B;CAIhD;AAED,qBAAa,cAAe,SAAQ,cAAc;gBACpC,OAAO,SAAkB;CAItC"}
package/dist/errors.js ADDED
@@ -0,0 +1,51 @@
1
+ export class VerbatimsError extends Error {
2
+ statusCode;
3
+ code;
4
+ constructor(message, statusCode, code) {
5
+ super(message);
6
+ this.statusCode = statusCode;
7
+ this.code = code;
8
+ this.name = 'VerbatimsError';
9
+ }
10
+ }
11
+ export class NotFoundError extends VerbatimsError {
12
+ constructor(message = 'Resource not found') {
13
+ super(message, 404, 'NOT_FOUND');
14
+ this.name = 'NotFoundError';
15
+ }
16
+ }
17
+ export class RateLimitError extends VerbatimsError {
18
+ retryAfter;
19
+ limit;
20
+ remaining;
21
+ reset;
22
+ constructor(message, retryAfter, limit, remaining, reset) {
23
+ super(message, 429, 'RATE_LIMITED');
24
+ this.retryAfter = retryAfter;
25
+ this.limit = limit;
26
+ this.remaining = remaining;
27
+ this.reset = reset;
28
+ this.name = 'RateLimitError';
29
+ }
30
+ }
31
+ export class ValidationError extends VerbatimsError {
32
+ errors;
33
+ constructor(message, errors) {
34
+ super(message, 400, 'VALIDATION_ERROR');
35
+ this.errors = errors;
36
+ this.name = 'ValidationError';
37
+ }
38
+ }
39
+ export class AuthError extends VerbatimsError {
40
+ constructor(message = 'Authentication required') {
41
+ super(message, 401, 'AUTH_ERROR');
42
+ this.name = 'AuthError';
43
+ }
44
+ }
45
+ export class ForbiddenError extends VerbatimsError {
46
+ constructor(message = 'Access denied') {
47
+ super(message, 403, 'FORBIDDEN');
48
+ this.name = 'ForbiddenError';
49
+ }
50
+ }
51
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAG9B;IACA;IAHT,YACE,OAAe,EACR,UAAkB,EAClB,IAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAA;QAHP,eAAU,GAAV,UAAU,CAAQ;QAClB,SAAI,GAAJ,IAAI,CAAS;QAGpB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,cAAc;IAC/C,YAAY,OAAO,GAAG,oBAAoB;QACxC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,cAAc;IAGvC;IACA;IACA;IACA;IALT,YACE,OAAe,EACR,UAAkB,EAClB,KAAa,EACb,SAAiB,EACjB,KAAa;QAEpB,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAA;QAL5B,eAAU,GAAV,UAAU,CAAQ;QAClB,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QACjB,UAAK,GAAL,KAAK,CAAQ;QAGpB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAGxC;IAFT,YACE,OAAe,EACR,MAAiB;QAExB,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,kBAAkB,CAAC,CAAA;QAFhC,WAAM,GAAN,MAAM,CAAW;QAGxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,cAAc;IAC3C,YAAY,OAAO,GAAG,yBAAyB;QAC7C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,cAAc;IAChD,YAAY,OAAO,GAAG,eAAe;QACnC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import { VerbatimsClient as BaseClient } from './client';
2
+ import { QuotesResource } from './resources/quotes';
3
+ import { AuthorsResource } from './resources/authors';
4
+ import { ReferencesResource } from './resources/references';
5
+ import { TagsResource } from './resources/tags';
6
+ import { CollectionsResource } from './resources/collections';
7
+ import { SearchResource } from './resources/search';
8
+ export type { ClientOptions } from './client';
9
+ export { paginate } from './pagination';
10
+ export type { PageFetcher } from './pagination';
11
+ export { VerbatimsError, NotFoundError, RateLimitError, ValidationError, AuthError, ForbiddenError, } from './errors';
12
+ export type { QuoteWithRelations, Author, QuoteReference, PaginationMeta, ApiResponse, ListQuotesParams, ListAuthorsParams, ListReferencesParams, SearchParams, CreateQuoteData, UpdateQuoteData, CreateAuthorData, UpdateAuthorData, CreateReferenceData, UpdateReferenceData, CreateCollectionData, } from './types';
13
+ export declare class VerbatimsClient extends BaseClient {
14
+ quotes: QuotesResource;
15
+ authors: AuthorsResource;
16
+ references: ReferencesResource;
17
+ tags: TagsResource;
18
+ collections: CollectionsResource;
19
+ search: SearchResource;
20
+ constructor(apiKey: string, opts?: ConstructorParameters<typeof BaseClient>[1]);
21
+ }
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,SAAS,EACT,cAAc,GACf,MAAM,UAAU,CAAA;AAEjB,YAAY,EACV,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAA;AAEhB,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,kBAAkB,CAAA;IAC9B,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,mBAAmB,CAAA;IAChC,MAAM,EAAE,cAAc,CAAA;gBAEV,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;CAS/E"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { VerbatimsClient as BaseClient } from './client';
2
+ import { QuotesResource } from './resources/quotes';
3
+ import { AuthorsResource } from './resources/authors';
4
+ import { ReferencesResource } from './resources/references';
5
+ import { TagsResource } from './resources/tags';
6
+ import { CollectionsResource } from './resources/collections';
7
+ import { SearchResource } from './resources/search';
8
+ export { paginate } from './pagination';
9
+ export { VerbatimsError, NotFoundError, RateLimitError, ValidationError, AuthError, ForbiddenError, } from './errors';
10
+ export class VerbatimsClient extends BaseClient {
11
+ quotes;
12
+ authors;
13
+ references;
14
+ tags;
15
+ collections;
16
+ search;
17
+ constructor(apiKey, opts) {
18
+ super(apiKey, opts);
19
+ this.quotes = new QuotesResource(this);
20
+ this.authors = new AuthorsResource(this);
21
+ this.references = new ReferencesResource(this);
22
+ this.tags = new TagsResource(this);
23
+ this.collections = new CollectionsResource(this);
24
+ this.search = new SearchResource(this);
25
+ }
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,SAAS,EACT,cAAc,GACf,MAAM,UAAU,CAAA;AAqBjB,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,MAAM,CAAgB;IACtB,OAAO,CAAiB;IACxB,UAAU,CAAoB;IAC9B,IAAI,CAAc;IAClB,WAAW,CAAqB;IAChC,MAAM,CAAgB;IAEtB,YAAY,MAAc,EAAE,IAAkD;QAC5E,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;QACxC,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { PaginationMeta } from './types';
2
+ export interface PageFetcher<T> {
3
+ (page: number): Promise<{
4
+ data?: T[];
5
+ pagination?: PaginationMeta;
6
+ }>;
7
+ }
8
+ export declare function paginate<T>(fetchPage: PageFetcher<T>): AsyncGenerator<T>;
9
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;QACV,UAAU,CAAC,EAAE,cAAc,CAAA;KAC5B,CAAC,CAAA;CACH;AAED,wBAAuB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAe/E"}
@@ -0,0 +1,16 @@
1
+ export async function* paginate(fetchPage) {
2
+ let page = 1;
3
+ while (true) {
4
+ const result = await fetchPage(page);
5
+ const items = result.data;
6
+ if (!items || items.length === 0)
7
+ break;
8
+ for (const item of items) {
9
+ yield item;
10
+ }
11
+ if (!result.pagination?.hasMore)
12
+ break;
13
+ page++;
14
+ }
15
+ }
16
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAAI,SAAyB;IAC1D,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;QACzB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,MAAK;QAEvC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,CAAA;QACZ,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO;YAAE,MAAK;QACtC,IAAI,EAAE,CAAA;IACR,CAAC;AACH,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { z } from 'zod/v4';
2
+ import type { VerbatimsClient } from '../client';
3
+ import type { ListAuthorsParams, CreateAuthorData, UpdateAuthorData } from '../types';
4
+ declare const authorSchema: z.ZodObject<{
5
+ id: z.ZodNumber;
6
+ name: z.ZodString;
7
+ is_fictional: z.ZodOptional<z.ZodBoolean>;
8
+ image_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ job: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ birth_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ birth_location: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ death_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ death_location: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ views_count: z.ZodNumber;
16
+ likes_count: z.ZodNumber;
17
+ shares_count: z.ZodNumber;
18
+ quotes_count: z.ZodOptional<z.ZodNumber>;
19
+ created_at: z.ZodString;
20
+ updated_at: z.ZodString;
21
+ }, z.core.$strip>;
22
+ type AuthorItem = z.infer<typeof authorSchema>;
23
+ export declare class AuthorsResource {
24
+ private client;
25
+ constructor(client: VerbatimsClient);
26
+ list(params?: ListAuthorsParams): Promise<{
27
+ success: true;
28
+ data?: {
29
+ id: number;
30
+ name: string;
31
+ views_count: number;
32
+ likes_count: number;
33
+ shares_count: number;
34
+ created_at: string;
35
+ updated_at: string;
36
+ is_fictional?: boolean | undefined;
37
+ image_url?: string | null | undefined;
38
+ job?: string | null | undefined;
39
+ description?: string | null | undefined;
40
+ birth_date?: string | null | undefined;
41
+ birth_location?: string | null | undefined;
42
+ death_date?: string | null | undefined;
43
+ death_location?: string | null | undefined;
44
+ quotes_count?: number | undefined;
45
+ }[] | undefined;
46
+ message?: string | undefined;
47
+ pagination?: {
48
+ page: number;
49
+ limit: number;
50
+ total: number;
51
+ totalPages: number;
52
+ hasMore: boolean;
53
+ } | undefined;
54
+ }>;
55
+ paginate(params?: ListAuthorsParams): AsyncGenerator<AuthorItem>;
56
+ get(id: number): Promise<{
57
+ success: true;
58
+ data?: {
59
+ id: number;
60
+ name: string;
61
+ views_count: number;
62
+ likes_count: number;
63
+ shares_count: number;
64
+ created_at: string;
65
+ updated_at: string;
66
+ is_fictional?: boolean | undefined;
67
+ image_url?: string | null | undefined;
68
+ job?: string | null | undefined;
69
+ description?: string | null | undefined;
70
+ birth_date?: string | null | undefined;
71
+ birth_location?: string | null | undefined;
72
+ death_date?: string | null | undefined;
73
+ death_location?: string | null | undefined;
74
+ quotes_count?: number | undefined;
75
+ } | undefined;
76
+ message?: string | undefined;
77
+ pagination?: {
78
+ page: number;
79
+ limit: number;
80
+ total: number;
81
+ totalPages: number;
82
+ hasMore: boolean;
83
+ } | undefined;
84
+ }>;
85
+ create(data: CreateAuthorData): Promise<{
86
+ success: true;
87
+ data?: {
88
+ id: number;
89
+ name: string;
90
+ views_count: number;
91
+ likes_count: number;
92
+ shares_count: number;
93
+ created_at: string;
94
+ updated_at: string;
95
+ is_fictional?: boolean | undefined;
96
+ image_url?: string | null | undefined;
97
+ job?: string | null | undefined;
98
+ description?: string | null | undefined;
99
+ birth_date?: string | null | undefined;
100
+ birth_location?: string | null | undefined;
101
+ death_date?: string | null | undefined;
102
+ death_location?: string | null | undefined;
103
+ quotes_count?: number | undefined;
104
+ } | undefined;
105
+ message?: string | undefined;
106
+ pagination?: {
107
+ page: number;
108
+ limit: number;
109
+ total: number;
110
+ totalPages: number;
111
+ hasMore: boolean;
112
+ } | undefined;
113
+ }>;
114
+ update(id: number, data: UpdateAuthorData): Promise<{
115
+ success: true;
116
+ data?: {
117
+ id: number;
118
+ name: string;
119
+ views_count: number;
120
+ likes_count: number;
121
+ shares_count: number;
122
+ created_at: string;
123
+ updated_at: string;
124
+ is_fictional?: boolean | undefined;
125
+ image_url?: string | null | undefined;
126
+ job?: string | null | undefined;
127
+ description?: string | null | undefined;
128
+ birth_date?: string | null | undefined;
129
+ birth_location?: string | null | undefined;
130
+ death_date?: string | null | undefined;
131
+ death_location?: string | null | undefined;
132
+ quotes_count?: number | undefined;
133
+ } | undefined;
134
+ message?: string | undefined;
135
+ pagination?: {
136
+ page: number;
137
+ limit: number;
138
+ total: number;
139
+ totalPages: number;
140
+ hasMore: boolean;
141
+ } | undefined;
142
+ }>;
143
+ }
144
+ export {};
145
+ //# sourceMappingURL=authors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authors.d.ts","sourceRoot":"","sources":["../../src/resources/authors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,KAAK,EAAU,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE7F,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;iBAiBhB,CAAA;AAKF,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE9C,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,eAAe;IAErC,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIrC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,cAAc,CAAC,UAAU,CAAC;IAS1D,GAAG,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAId,MAAM,CAAC,IAAI,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGhD"}