@signa-so/sdk 0.2.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/README.md +180 -0
- package/dist/_internals/fetch-with-retry.d.ts +31 -0
- package/dist/_internals/fetch-with-retry.d.ts.map +1 -0
- package/dist/_internals/fetch-with-retry.js +113 -0
- package/dist/_internals/fetch-with-retry.js.map +1 -0
- package/dist/_internals/query-string.d.ts +10 -0
- package/dist/_internals/query-string.d.ts.map +1 -0
- package/dist/_internals/query-string.js +34 -0
- package/dist/_internals/query-string.js.map +1 -0
- package/dist/_internals/retry.d.ts +7 -0
- package/dist/_internals/retry.d.ts.map +1 -0
- package/dist/_internals/retry.js +23 -0
- package/dist/_internals/retry.js.map +1 -0
- package/dist/client.d.ts +68 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +104 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +66 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +141 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/api-types.d.ts +6219 -0
- package/dist/generated/api-types.d.ts.map +1 -0
- package/dist/generated/api-types.js +6 -0
- package/dist/generated/api-types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +60 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +98 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resource.d.ts +27 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +80 -0
- package/dist/resource.js.map +1 -0
- package/dist/resources/alerts.d.ts +20 -0
- package/dist/resources/alerts.d.ts.map +1 -0
- package/dist/resources/alerts.js +30 -0
- package/dist/resources/alerts.js.map +1 -0
- package/dist/resources/attorneys.d.ts +39 -0
- package/dist/resources/attorneys.d.ts.map +1 -0
- package/dist/resources/attorneys.js +57 -0
- package/dist/resources/attorneys.js.map +1 -0
- package/dist/resources/events.d.ts +10 -0
- package/dist/resources/events.d.ts.map +1 -0
- package/dist/resources/events.js +14 -0
- package/dist/resources/events.js.map +1 -0
- package/dist/resources/firms.d.ts +40 -0
- package/dist/resources/firms.d.ts.map +1 -0
- package/dist/resources/firms.js +61 -0
- package/dist/resources/firms.js.map +1 -0
- package/dist/resources/owners.d.ts +39 -0
- package/dist/resources/owners.d.ts.map +1 -0
- package/dist/resources/owners.js +60 -0
- package/dist/resources/owners.js.map +1 -0
- package/dist/resources/platform.d.ts +29 -0
- package/dist/resources/platform.d.ts.map +1 -0
- package/dist/resources/platform.js +46 -0
- package/dist/resources/platform.js.map +1 -0
- package/dist/resources/portfolios.d.ts +32 -0
- package/dist/resources/portfolios.d.ts.map +1 -0
- package/dist/resources/portfolios.js +49 -0
- package/dist/resources/portfolios.js.map +1 -0
- package/dist/resources/proceedings.d.ts +23 -0
- package/dist/resources/proceedings.d.ts.map +1 -0
- package/dist/resources/proceedings.js +30 -0
- package/dist/resources/proceedings.js.map +1 -0
- package/dist/resources/references.d.ts +106 -0
- package/dist/resources/references.d.ts.map +1 -0
- package/dist/resources/references.js +136 -0
- package/dist/resources/references.js.map +1 -0
- package/dist/resources/saved-searches.d.ts +22 -0
- package/dist/resources/saved-searches.d.ts.map +1 -0
- package/dist/resources/saved-searches.js +35 -0
- package/dist/resources/saved-searches.js.map +1 -0
- package/dist/resources/search.d.ts +27 -0
- package/dist/resources/search.d.ts.map +1 -0
- package/dist/resources/search.js +36 -0
- package/dist/resources/search.js.map +1 -0
- package/dist/resources/trademarks.d.ts +80 -0
- package/dist/resources/trademarks.d.ts.map +1 -0
- package/dist/resources/trademarks.js +117 -0
- package/dist/resources/trademarks.js.map +1 -0
- package/dist/resources/watches.d.ts +18 -0
- package/dist/resources/watches.d.ts.map +1 -0
- package/dist/resources/watches.js +31 -0
- package/dist/resources/watches.js.map +1 -0
- package/dist/types.d.ts +719 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# @signa/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the Signa trademark intelligence API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @signa/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import Signa from '@signa/sdk';
|
|
15
|
+
|
|
16
|
+
const signa = new Signa({ api_key: 'sig_live_xxx' });
|
|
17
|
+
|
|
18
|
+
// Retrieve a trademark
|
|
19
|
+
const tm = await signa.trademarks.retrieve('tm_abc123');
|
|
20
|
+
|
|
21
|
+
// Search trademarks
|
|
22
|
+
const results = await signa.search.query({ query: 'nike', office: 'USPTO' });
|
|
23
|
+
|
|
24
|
+
// List with auto-pagination
|
|
25
|
+
const page = await signa.trademarks.list({ limit: 50 });
|
|
26
|
+
for (const tm of page.data) {
|
|
27
|
+
console.log(tm.mark_text);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const signa = new Signa({
|
|
35
|
+
api_key: 'sig_live_xxx', // Required (or set SIGNA_API_KEY env var)
|
|
36
|
+
base_url: 'https://api.signa.so', // Default
|
|
37
|
+
timeout: 30_000, // 30s default
|
|
38
|
+
max_retries: 2, // Automatic retry with backoff
|
|
39
|
+
debug: false, // Log request/response details
|
|
40
|
+
fetch: customFetch, // Custom fetch implementation
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Resources
|
|
45
|
+
|
|
46
|
+
All resources follow the same pattern: `.retrieve(id)`, `.list(params)`, plus resource-specific methods.
|
|
47
|
+
|
|
48
|
+
### `signa.trademarks`
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
await signa.trademarks.retrieve('tm_xxx');
|
|
52
|
+
await signa.trademarks.retrieve('tm_xxx', { expand: ['owners', 'attorneys'] });
|
|
53
|
+
await signa.trademarks.list({ office: 'USPTO', status: 'registered', limit: 50 });
|
|
54
|
+
await signa.trademarks.history('tm_xxx');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `signa.owners`
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
await signa.owners.retrieve('own_xxx');
|
|
61
|
+
await signa.owners.list({ query: 'Nike', country: 'US' });
|
|
62
|
+
await signa.owners.trademarks('own_xxx');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `signa.attorneys`
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
await signa.attorneys.retrieve('att_xxx');
|
|
69
|
+
await signa.attorneys.list({ query: 'Smith' });
|
|
70
|
+
await signa.attorneys.trademarks('att_xxx');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `signa.firms`
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
await signa.firms.retrieve('firm_xxx');
|
|
77
|
+
await signa.firms.list({ query: 'Baker McKenzie' });
|
|
78
|
+
await signa.firms.attorneys('firm_xxx');
|
|
79
|
+
await signa.firms.trademarks('firm_xxx');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `signa.proceedings`
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
await signa.proceedings.retrieve('prc_xxx');
|
|
86
|
+
await signa.proceedings.list({ trademark_id: 'tm_xxx' });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `signa.search`
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
await signa.search.query({
|
|
93
|
+
query: 'nike',
|
|
94
|
+
office: 'USPTO',
|
|
95
|
+
status: 'registered',
|
|
96
|
+
nice_class: [25, 35],
|
|
97
|
+
from: 0,
|
|
98
|
+
size: 20,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await signa.search.suggest({ query: 'nik', size: 5 });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `signa.references`
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
await signa.references.classifications(); // Nice classes
|
|
108
|
+
await signa.references.offices(); // Trademark offices
|
|
109
|
+
await signa.references.jurisdictions(); // Jurisdictions
|
|
110
|
+
await signa.references.statuses(); // Status codes
|
|
111
|
+
await signa.references.eventTypes(); // Event types
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Error Handling
|
|
115
|
+
|
|
116
|
+
All API errors throw typed exceptions for `instanceof` checks:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
try {
|
|
120
|
+
await signa.trademarks.retrieve('tm_invalid');
|
|
121
|
+
} catch (err) {
|
|
122
|
+
if (err instanceof Signa.NotFoundError) {
|
|
123
|
+
console.log('Not found:', err.message);
|
|
124
|
+
} else if (err instanceof Signa.RateLimitError) {
|
|
125
|
+
console.log('Rate limited, retry after:', err.retryAfter);
|
|
126
|
+
} else if (err instanceof Signa.AuthenticationError) {
|
|
127
|
+
console.log('Bad API key');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Error hierarchy:**
|
|
133
|
+
|
|
134
|
+
| Class | HTTP Status | Description |
|
|
135
|
+
|-------|-------------|-------------|
|
|
136
|
+
| `SignaError` | — | Base class (network errors, timeouts) |
|
|
137
|
+
| `SignaAPIError` | Any | Base for all API errors |
|
|
138
|
+
| `BadRequestError` | 400 | Invalid parameters |
|
|
139
|
+
| `AuthenticationError` | 401 | Missing or invalid API key |
|
|
140
|
+
| `PermissionError` | 403 | Insufficient scope |
|
|
141
|
+
| `NotFoundError` | 404 | Resource not found |
|
|
142
|
+
| `RateLimitError` | 429 | Rate limit exceeded |
|
|
143
|
+
| `InternalServerError` | 500 | Server error |
|
|
144
|
+
| `ConnectionError` | — | Network connectivity failure |
|
|
145
|
+
| `TimeoutError` | — | Request timeout |
|
|
146
|
+
|
|
147
|
+
## Pagination
|
|
148
|
+
|
|
149
|
+
List endpoints return a `SignaList` with cursor-based pagination:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
const page = await signa.trademarks.list({ limit: 100 });
|
|
153
|
+
|
|
154
|
+
console.log(page.data); // Trademark[]
|
|
155
|
+
console.log(page.has_more); // boolean
|
|
156
|
+
console.log(page.next_cursor); // string | null
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Type Generation
|
|
160
|
+
|
|
161
|
+
The SDK auto-generates types from the API's OpenAPI spec:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
bun run generate:types # Regenerate from API OpenAPI spec
|
|
165
|
+
bun run check:types-sync # Verify types are up-to-date (CI check)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Scripts
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
bun run build # Compile TypeScript
|
|
172
|
+
bun run test # Run tests (uses msw for API mocking)
|
|
173
|
+
bun run dev # Watch mode
|
|
174
|
+
bun run typecheck # Type check
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Requirements
|
|
178
|
+
|
|
179
|
+
- Node.js >= 18 (uses native `fetch`)
|
|
180
|
+
- MIT License
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RequestOptions } from '../types.js';
|
|
2
|
+
export interface FetchConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
timeout: number;
|
|
6
|
+
maxRetries: number;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
fetch: typeof globalThis.fetch;
|
|
9
|
+
}
|
|
10
|
+
export interface FetchRequest {
|
|
11
|
+
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
12
|
+
path: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
options?: RequestOptions;
|
|
15
|
+
/** Override the default Accept header (e.g., 'text/calendar' for iCal). */
|
|
16
|
+
accept?: string;
|
|
17
|
+
/** When true, return the raw response text instead of parsing JSON. */
|
|
18
|
+
rawResponse?: boolean;
|
|
19
|
+
/** Set to 'manual' to capture redirect URLs instead of following them. */
|
|
20
|
+
redirect?: 'follow' | 'manual';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Execute an HTTP request with timeout, retries, and error mapping.
|
|
24
|
+
* Returns the parsed JSON body.
|
|
25
|
+
*/
|
|
26
|
+
export declare function fetchWithRetry(config: FetchConfig, request: FetchRequest): Promise<{
|
|
27
|
+
body: unknown;
|
|
28
|
+
headers: Headers;
|
|
29
|
+
status: number;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=fetch-with-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-with-retry.d.ts","sourceRoot":"","sources":["../../src/_internals/fetch-with-retry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA+H9D"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ConnectionError, TimeoutError, createAPIError } from '../errors.js';
|
|
2
|
+
import { shouldRetry, getRetryDelay, sleep } from './retry.js';
|
|
3
|
+
import { SDK_VERSION } from '../version.js';
|
|
4
|
+
/**
|
|
5
|
+
* Execute an HTTP request with timeout, retries, and error mapping.
|
|
6
|
+
* Returns the parsed JSON body.
|
|
7
|
+
*/
|
|
8
|
+
export async function fetchWithRetry(config, request) {
|
|
9
|
+
const timeout = request.options?.timeout ?? config.timeout;
|
|
10
|
+
const maxRetries = request.options?.max_retries ?? config.maxRetries;
|
|
11
|
+
const url = `${config.baseUrl}${request.path}`;
|
|
12
|
+
const headers = {
|
|
13
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
14
|
+
'Accept': request.accept ?? 'application/json',
|
|
15
|
+
'User-Agent': `signa-sdk-typescript/${SDK_VERSION}`,
|
|
16
|
+
'X-Signa-Client': `typescript/${SDK_VERSION}`,
|
|
17
|
+
...(request.body !== undefined && { 'Content-Type': 'application/json' }),
|
|
18
|
+
...request.options?.headers,
|
|
19
|
+
};
|
|
20
|
+
if (request.options?.idempotency_key) {
|
|
21
|
+
headers['Idempotency-Key'] = request.options.idempotency_key;
|
|
22
|
+
}
|
|
23
|
+
let lastError;
|
|
24
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
25
|
+
if (attempt > 0) {
|
|
26
|
+
const delay = getRetryDelay(lastError, attempt - 1);
|
|
27
|
+
if (config.debug) {
|
|
28
|
+
console.error(`[signa] Retrying in ${Math.round(delay)}ms (attempt ${attempt + 1}/${maxRetries + 1})`);
|
|
29
|
+
}
|
|
30
|
+
await sleep(delay);
|
|
31
|
+
}
|
|
32
|
+
// ── 1. Fire the request (catch only network/timeout errors) ─────
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
if (config.debug) {
|
|
36
|
+
console.error(`[signa] → ${request.method} ${url} (attempt ${attempt + 1}/${maxRetries + 1})`);
|
|
37
|
+
}
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
40
|
+
try {
|
|
41
|
+
response = await config.fetch(url, {
|
|
42
|
+
method: request.method,
|
|
43
|
+
headers,
|
|
44
|
+
body: request.body !== undefined ? JSON.stringify(request.body) : undefined,
|
|
45
|
+
signal: controller.signal,
|
|
46
|
+
redirect: request.redirect ?? 'follow',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
// AbortController abort → timeout
|
|
55
|
+
if (e instanceof DOMException && e.name === 'AbortError') {
|
|
56
|
+
const timeoutError = new TimeoutError(timeout);
|
|
57
|
+
if (shouldRetry(timeoutError, attempt, maxRetries)) {
|
|
58
|
+
lastError = timeoutError;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
throw timeoutError;
|
|
62
|
+
}
|
|
63
|
+
// Network error (DNS failure, connection refused, etc.)
|
|
64
|
+
const connError = new ConnectionError(`Connection failed: ${e instanceof Error ? e.message : String(e)}`, e instanceof Error ? e : undefined);
|
|
65
|
+
if (shouldRetry(connError, attempt, maxRetries)) {
|
|
66
|
+
lastError = connError;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
throw connError;
|
|
70
|
+
}
|
|
71
|
+
// ── 2. Handle the response (no try/catch — errors throw directly) ─
|
|
72
|
+
if (config.debug) {
|
|
73
|
+
const reqId = response.headers.get('x-request-id') ?? '';
|
|
74
|
+
console.error(`[signa] ← ${response.status} ${response.statusText} ${reqId}`);
|
|
75
|
+
}
|
|
76
|
+
// Handle manual redirects — return the Location header as body
|
|
77
|
+
if (request.redirect === 'manual' && response.status >= 300 && response.status < 400) {
|
|
78
|
+
const location = response.headers.get('location') ?? '';
|
|
79
|
+
return { body: location, headers: response.headers, status: response.status };
|
|
80
|
+
}
|
|
81
|
+
if (response.ok) {
|
|
82
|
+
const body = request.rawResponse
|
|
83
|
+
? await response.text()
|
|
84
|
+
: await response.json();
|
|
85
|
+
return { body, headers: response.headers, status: response.status };
|
|
86
|
+
}
|
|
87
|
+
// Error response — parse body and create typed error
|
|
88
|
+
let errorBody;
|
|
89
|
+
try {
|
|
90
|
+
errorBody = await response.json();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
errorBody = {
|
|
94
|
+
error: {
|
|
95
|
+
type: 'https://api.signa.so/errors/unknown',
|
|
96
|
+
title: 'Unknown Error',
|
|
97
|
+
status: response.status,
|
|
98
|
+
detail: `HTTP ${response.status} ${response.statusText}`,
|
|
99
|
+
},
|
|
100
|
+
request_id: response.headers.get('x-request-id') ?? 'unknown',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const apiError = createAPIError(response.status, errorBody, response.headers);
|
|
104
|
+
if (shouldRetry(apiError, attempt, maxRetries)) {
|
|
105
|
+
lastError = apiError;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
throw apiError;
|
|
109
|
+
}
|
|
110
|
+
// Should not reach here, but if it does, throw the last error
|
|
111
|
+
throw lastError;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=fetch-with-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-with-retry.js","sourceRoot":"","sources":["../../src/_internals/fetch-with-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAA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4
|
+
* - Arrays with bracket keys (e.g., `jurisdictions[]`) emit repeated params
|
|
5
|
+
* - Other arrays are serialized as comma-separated (e.g., `include`)
|
|
6
|
+
* - Numbers are stringified
|
|
7
|
+
* - Bracket-notation keys like 'filing_date[gte]' pass through as-is
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildQueryString(params: Record<string, unknown>): string;
|
|
10
|
+
//# sourceMappingURL=query-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-string.d.ts","sourceRoot":"","sources":["../../src/_internals/query-string.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAwBxE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a URL query string from a params object.
|
|
3
|
+
* - Undefined/null values are omitted
|
|
4
|
+
* - Arrays with bracket keys (e.g., `jurisdictions[]`) emit repeated params
|
|
5
|
+
* - Other arrays are serialized as comma-separated (e.g., `include`)
|
|
6
|
+
* - Numbers are stringified
|
|
7
|
+
* - Bracket-notation keys like 'filing_date[gte]' pass through as-is
|
|
8
|
+
*/
|
|
9
|
+
export function buildQueryString(params) {
|
|
10
|
+
const parts = [];
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
if (value === undefined || value === null)
|
|
13
|
+
continue;
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
if (value.length > 0) {
|
|
16
|
+
if (key.endsWith('[]')) {
|
|
17
|
+
// Repeated params for bracket-notation array keys
|
|
18
|
+
for (const item of value) {
|
|
19
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Comma-separated for non-bracket keys (e.g., include)
|
|
24
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.join(','))}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return parts.length > 0 ? `?${parts.join('&')}` : '';
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=query-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-string.js","sourceRoot":"","sources":["../../src/_internals/query-string.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA+B;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAEpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACvB,kDAAkD;oBAClD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;wBACzB,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;oBAC/E,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,uDAAuD;oBACvD,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Calculate backoff delay with jitter. */
|
|
2
|
+
export declare function calculateBackoff(attempt: number): number;
|
|
3
|
+
/** Get the delay before the next retry attempt. */
|
|
4
|
+
export declare function getRetryDelay(error: unknown, attempt: number): number;
|
|
5
|
+
export declare function shouldRetry(error: unknown, attempt: number, maxRetries: number): boolean;
|
|
6
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/_internals/retry.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGxF;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isRetryable, RateLimitError } from '../errors.js';
|
|
2
|
+
/** Calculate backoff delay with jitter. */
|
|
3
|
+
export function calculateBackoff(attempt) {
|
|
4
|
+
const base = Math.min(500 * 2 ** attempt, 8000);
|
|
5
|
+
const jitter = Math.random() * 500;
|
|
6
|
+
return base + jitter;
|
|
7
|
+
}
|
|
8
|
+
/** Get the delay before the next retry attempt. */
|
|
9
|
+
export function getRetryDelay(error, attempt) {
|
|
10
|
+
if (error instanceof RateLimitError && error.retry_after > 0) {
|
|
11
|
+
return error.retry_after * 1000;
|
|
12
|
+
}
|
|
13
|
+
return calculateBackoff(attempt);
|
|
14
|
+
}
|
|
15
|
+
export function shouldRetry(error, attempt, maxRetries) {
|
|
16
|
+
if (attempt >= maxRetries)
|
|
17
|
+
return false;
|
|
18
|
+
return isRetryable(error);
|
|
19
|
+
}
|
|
20
|
+
export function sleep(ms) {
|
|
21
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/_internals/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE3D,2CAA2C;AAC3C,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;IACnC,OAAO,IAAI,GAAG,MAAM,CAAC;AACvB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,OAAe;IAC3D,IAAI,KAAK,YAAY,cAAc,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;QAC7D,OAAO,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;IAClC,CAAC;IACD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,OAAe,EAAE,UAAkB;IAC7E,IAAI,OAAO,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ClientOptions } from './types.js';
|
|
2
|
+
import { SignaError, SignaAPIError, BadRequestError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, InternalServerError, ConnectionError, TimeoutError } from './errors.js';
|
|
3
|
+
import { Trademarks } from './resources/trademarks.js';
|
|
4
|
+
import { Owners } from './resources/owners.js';
|
|
5
|
+
import { Attorneys } from './resources/attorneys.js';
|
|
6
|
+
import { Firms } from './resources/firms.js';
|
|
7
|
+
import { Proceedings } from './resources/proceedings.js';
|
|
8
|
+
import { Search } from './resources/search.js';
|
|
9
|
+
import { References } from './resources/references.js';
|
|
10
|
+
import { Portfolios } from './resources/portfolios.js';
|
|
11
|
+
import { SavedSearches } from './resources/saved-searches.js';
|
|
12
|
+
import { Watches } from './resources/watches.js';
|
|
13
|
+
import { Alerts } from './resources/alerts.js';
|
|
14
|
+
import { Events } from './resources/events.js';
|
|
15
|
+
import { Platform } from './resources/platform.js';
|
|
16
|
+
/**
|
|
17
|
+
* Signa API client.
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import Signa from '@signa/sdk';
|
|
21
|
+
*
|
|
22
|
+
* const signa = new Signa({ api_key: 'sig_live_xxx' });
|
|
23
|
+
* const tm = await signa.trademarks.retrieve('tm_abc123');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Signa {
|
|
27
|
+
static readonly SignaError: typeof SignaError;
|
|
28
|
+
static readonly SignaAPIError: typeof SignaAPIError;
|
|
29
|
+
static readonly BadRequestError: typeof BadRequestError;
|
|
30
|
+
static readonly AuthenticationError: typeof AuthenticationError;
|
|
31
|
+
static readonly PermissionError: typeof PermissionError;
|
|
32
|
+
static readonly NotFoundError: typeof NotFoundError;
|
|
33
|
+
static readonly ConflictError: typeof ConflictError;
|
|
34
|
+
static readonly RateLimitError: typeof RateLimitError;
|
|
35
|
+
static readonly InternalServerError: typeof InternalServerError;
|
|
36
|
+
static readonly ConnectionError: typeof ConnectionError;
|
|
37
|
+
static readonly TimeoutError: typeof TimeoutError;
|
|
38
|
+
/** Trademark operations: retrieve, list, history. */
|
|
39
|
+
readonly trademarks: Trademarks;
|
|
40
|
+
/** Owner operations: retrieve, list, trademarks. */
|
|
41
|
+
readonly owners: Owners;
|
|
42
|
+
/** Attorney operations: retrieve, list, trademarks. */
|
|
43
|
+
readonly attorneys: Attorneys;
|
|
44
|
+
/** Firm operations: retrieve, list, attorneys, trademarks. */
|
|
45
|
+
readonly firms: Firms;
|
|
46
|
+
/** Proceeding operations: retrieve, list. */
|
|
47
|
+
readonly proceedings: Proceedings;
|
|
48
|
+
/** Search operations: query, suggest. */
|
|
49
|
+
readonly search: Search;
|
|
50
|
+
/** Reference data: classifications, offices, jurisdictions, statuses, event types, design codes. */
|
|
51
|
+
readonly references: References;
|
|
52
|
+
/** Portfolio management: CRUD, marks, deadlines. */
|
|
53
|
+
readonly portfolios: Portfolios;
|
|
54
|
+
/** Saved search management: CRUD, re-execute. */
|
|
55
|
+
readonly savedSearches: SavedSearches;
|
|
56
|
+
/** Watch management: CRUD, watch-scoped alerts. */
|
|
57
|
+
readonly watches: Watches;
|
|
58
|
+
/** Alert operations: list, retrieve, acknowledge, dismiss, batch. */
|
|
59
|
+
readonly alerts: Alerts;
|
|
60
|
+
/** Event stream: list, retrieve with diffs. */
|
|
61
|
+
readonly events: Events;
|
|
62
|
+
/** Platform: identity, usage, API key management. */
|
|
63
|
+
readonly platform: Platform;
|
|
64
|
+
/** @internal */
|
|
65
|
+
private readonly _config;
|
|
66
|
+
constructor(opts?: ClientOptions);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAMnD;;;;;;;;;GASG;AACH,qBAAa,KAAK;IAEhB,MAAM,CAAC,QAAQ,CAAC,UA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QAAQ,CAAC;IAE5B,gBAAgB;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;gBAE1B,IAAI,GAAE,aAAkB;CA+BrC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { SignaError, SignaAPIError, BadRequestError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, InternalServerError, ConnectionError, TimeoutError, } from './errors.js';
|
|
2
|
+
import { Trademarks } from './resources/trademarks.js';
|
|
3
|
+
import { Owners } from './resources/owners.js';
|
|
4
|
+
import { Attorneys } from './resources/attorneys.js';
|
|
5
|
+
import { Firms } from './resources/firms.js';
|
|
6
|
+
import { Proceedings } from './resources/proceedings.js';
|
|
7
|
+
import { Search } from './resources/search.js';
|
|
8
|
+
import { References } from './resources/references.js';
|
|
9
|
+
import { Portfolios } from './resources/portfolios.js';
|
|
10
|
+
import { SavedSearches } from './resources/saved-searches.js';
|
|
11
|
+
import { Watches } from './resources/watches.js';
|
|
12
|
+
import { Alerts } from './resources/alerts.js';
|
|
13
|
+
import { Events } from './resources/events.js';
|
|
14
|
+
import { Platform } from './resources/platform.js';
|
|
15
|
+
const DEFAULT_BASE_URL = 'https://api.signa.so';
|
|
16
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
17
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
18
|
+
/**
|
|
19
|
+
* Signa API client.
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import Signa from '@signa/sdk';
|
|
23
|
+
*
|
|
24
|
+
* const signa = new Signa({ api_key: 'sig_live_xxx' });
|
|
25
|
+
* const tm = await signa.trademarks.retrieve('tm_abc123');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class Signa {
|
|
29
|
+
// ── Static error classes (enables Signa.NotFoundError pattern) ────
|
|
30
|
+
static SignaError = SignaError;
|
|
31
|
+
static SignaAPIError = SignaAPIError;
|
|
32
|
+
static BadRequestError = BadRequestError;
|
|
33
|
+
static AuthenticationError = AuthenticationError;
|
|
34
|
+
static PermissionError = PermissionError;
|
|
35
|
+
static NotFoundError = NotFoundError;
|
|
36
|
+
static ConflictError = ConflictError;
|
|
37
|
+
static RateLimitError = RateLimitError;
|
|
38
|
+
static InternalServerError = InternalServerError;
|
|
39
|
+
static ConnectionError = ConnectionError;
|
|
40
|
+
static TimeoutError = TimeoutError;
|
|
41
|
+
/** Trademark operations: retrieve, list, history. */
|
|
42
|
+
trademarks;
|
|
43
|
+
/** Owner operations: retrieve, list, trademarks. */
|
|
44
|
+
owners;
|
|
45
|
+
/** Attorney operations: retrieve, list, trademarks. */
|
|
46
|
+
attorneys;
|
|
47
|
+
/** Firm operations: retrieve, list, attorneys, trademarks. */
|
|
48
|
+
firms;
|
|
49
|
+
/** Proceeding operations: retrieve, list. */
|
|
50
|
+
proceedings;
|
|
51
|
+
/** Search operations: query, suggest. */
|
|
52
|
+
search;
|
|
53
|
+
/** Reference data: classifications, offices, jurisdictions, statuses, event types, design codes. */
|
|
54
|
+
references;
|
|
55
|
+
/** Portfolio management: CRUD, marks, deadlines. */
|
|
56
|
+
portfolios;
|
|
57
|
+
/** Saved search management: CRUD, re-execute. */
|
|
58
|
+
savedSearches;
|
|
59
|
+
/** Watch management: CRUD, watch-scoped alerts. */
|
|
60
|
+
watches;
|
|
61
|
+
/** Alert operations: list, retrieve, acknowledge, dismiss, batch. */
|
|
62
|
+
alerts;
|
|
63
|
+
/** Event stream: list, retrieve with diffs. */
|
|
64
|
+
events;
|
|
65
|
+
/** Platform: identity, usage, API key management. */
|
|
66
|
+
platform;
|
|
67
|
+
/** @internal */
|
|
68
|
+
_config;
|
|
69
|
+
constructor(opts = {}) {
|
|
70
|
+
const apiKey = opts.api_key ?? readEnv('SIGNA_API_KEY');
|
|
71
|
+
if (!apiKey) {
|
|
72
|
+
throw new SignaError('API key is required. Pass { api_key: "sig_live_..." } or set the SIGNA_API_KEY environment variable.');
|
|
73
|
+
}
|
|
74
|
+
this._config = {
|
|
75
|
+
apiKey,
|
|
76
|
+
baseUrl: (opts.base_url ?? DEFAULT_BASE_URL).replace(/\/+$/, ''),
|
|
77
|
+
timeout: opts.timeout ?? DEFAULT_TIMEOUT,
|
|
78
|
+
maxRetries: opts.max_retries ?? DEFAULT_MAX_RETRIES,
|
|
79
|
+
debug: opts.debug ?? false,
|
|
80
|
+
fetch: opts.fetch ?? globalThis.fetch,
|
|
81
|
+
};
|
|
82
|
+
this.trademarks = new Trademarks(this._config);
|
|
83
|
+
this.owners = new Owners(this._config);
|
|
84
|
+
this.attorneys = new Attorneys(this._config);
|
|
85
|
+
this.firms = new Firms(this._config);
|
|
86
|
+
this.proceedings = new Proceedings(this._config);
|
|
87
|
+
this.search = new Search(this._config);
|
|
88
|
+
this.references = new References(this._config);
|
|
89
|
+
this.portfolios = new Portfolios(this._config);
|
|
90
|
+
this.savedSearches = new SavedSearches(this._config);
|
|
91
|
+
this.watches = new Watches(this._config);
|
|
92
|
+
this.alerts = new Alerts(this._config);
|
|
93
|
+
this.events = new Events(this._config);
|
|
94
|
+
this.platform = new Platform(this._config);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Safely read an env var (works in Node, Bun, Deno; no-op in browsers/edge). */
|
|
98
|
+
function readEnv(name) {
|
|
99
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
100
|
+
return process.env[name];
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,C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