@no-mess/client 0.2.0 → 0.4.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 +108 -125
- package/dist/client.d.ts +12 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +250 -41
- package/dist/client.js.map +1 -1
- package/dist/error-utils.d.ts +20 -0
- package/dist/error-utils.d.ts.map +1 -0
- package/dist/error-utils.js +67 -0
- package/dist/error-utils.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +152 -22
- package/dist/index.js.map +1 -1
- package/dist/live-edit.d.ts.map +1 -1
- package/dist/live-edit.js +263 -102
- package/dist/live-edit.js.map +1 -1
- package/dist/logging.d.ts +6 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +58 -0
- package/dist/logging.js.map +1 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/no-mess-field.d.ts +10 -0
- package/dist/react/no-mess-field.d.ts.map +1 -0
- package/dist/react/no-mess-field.js +7 -0
- package/dist/react/no-mess-field.js.map +1 -0
- package/dist/react/no-mess-preview.d.ts +2 -6
- package/dist/react/no-mess-preview.d.ts.map +1 -1
- package/dist/react/no-mess-preview.js.map +1 -1
- package/dist/react/no-mess-provider.d.ts +21 -0
- package/dist/react/no-mess-provider.d.ts.map +1 -0
- package/dist/react/no-mess-provider.js +286 -0
- package/dist/react/no-mess-provider.js.map +1 -0
- package/dist/react/use-no-mess-live-edit.d.ts.map +1 -1
- package/dist/react/use-no-mess-live-edit.js +32 -2
- package/dist/react/use-no-mess-live-edit.js.map +1 -1
- package/dist/react/use-no-mess-preview.d.ts.map +1 -1
- package/dist/react/use-no-mess-preview.js +29 -6
- package/dist/react/use-no-mess-preview.js.map +1 -1
- package/dist/types.d.ts +78 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +23 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,54 +1,172 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNoMessCryptoError, createNoMessHttpError, createNoMessResponseError, extractRequestId, normalizeNoMessError, safeParseJsonText, } from "./error-utils.js";
|
|
2
|
+
import { createSdkLogger, warnOnce } from "./logging.js";
|
|
3
|
+
import { DEFAULT_API_URL } from "./types.js";
|
|
2
4
|
export class NoMessClient {
|
|
3
5
|
constructor(config) {
|
|
4
6
|
this.apiUrl = (config.apiUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
5
7
|
this.apiKey = config.apiKey;
|
|
8
|
+
this.logger = createSdkLogger(config.logger);
|
|
6
9
|
if (typeof window !== "undefined" &&
|
|
7
10
|
config.apiKey.startsWith("nm_") &&
|
|
8
11
|
!config.apiKey.startsWith("nm_pub_")) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
warnOnce(this.logger, "secret-key-in-browser", {
|
|
13
|
+
level: "warn",
|
|
14
|
+
code: "secret_key_in_browser",
|
|
15
|
+
message: "You are using a secret API key (nm_) in a browser environment. This exposes your secret key to end users. Use a publishable key (nm_pub_) for client-side code instead.",
|
|
16
|
+
scope: "client",
|
|
17
|
+
operation: "constructor",
|
|
18
|
+
timestamp: new Date().toISOString(),
|
|
19
|
+
context: {
|
|
20
|
+
apiUrl: this.apiUrl,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
12
23
|
}
|
|
13
24
|
}
|
|
14
|
-
|
|
25
|
+
emitErrorLog(error, scope, operation, level = "error", extraContext) {
|
|
26
|
+
this.logger({
|
|
27
|
+
level,
|
|
28
|
+
code: error.code,
|
|
29
|
+
message: error.message,
|
|
30
|
+
scope,
|
|
31
|
+
operation,
|
|
32
|
+
error,
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
context: {
|
|
35
|
+
status: error.status,
|
|
36
|
+
retryable: error.retryable,
|
|
37
|
+
requestId: error.requestId,
|
|
38
|
+
...error.details,
|
|
39
|
+
...extraContext,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async readResponseText(response, operation, method, url) {
|
|
44
|
+
try {
|
|
45
|
+
if (typeof response.text === "function") {
|
|
46
|
+
return await response.text();
|
|
47
|
+
}
|
|
48
|
+
if (typeof response.json === "function") {
|
|
49
|
+
return JSON.stringify(await response.json());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw createNoMessResponseError("Failed to read response body", {
|
|
54
|
+
kind: "response",
|
|
55
|
+
code: "invalid_success_response",
|
|
56
|
+
operation,
|
|
57
|
+
method,
|
|
58
|
+
url,
|
|
59
|
+
requestId: extractRequestId(response),
|
|
60
|
+
cause: error,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
async request({ method, path, params, body, operation, }) {
|
|
15
66
|
const url = new URL(`${this.apiUrl}${path}`);
|
|
16
67
|
if (params) {
|
|
17
68
|
for (const [key, value] of Object.entries(params)) {
|
|
18
69
|
url.searchParams.set(key, value);
|
|
19
70
|
}
|
|
20
71
|
}
|
|
21
|
-
const
|
|
72
|
+
const requestUrl = url.toString();
|
|
73
|
+
const init = {
|
|
74
|
+
method,
|
|
22
75
|
headers: {
|
|
23
76
|
Authorization: `Bearer ${this.apiKey}`,
|
|
24
77
|
"Content-Type": "application/json",
|
|
25
78
|
},
|
|
26
|
-
}
|
|
79
|
+
};
|
|
80
|
+
if (typeof body !== "undefined") {
|
|
81
|
+
init.body = JSON.stringify(body);
|
|
82
|
+
}
|
|
83
|
+
let response;
|
|
84
|
+
try {
|
|
85
|
+
response = await fetch(requestUrl, init);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const normalized = normalizeNoMessError(error, {
|
|
89
|
+
kind: "network",
|
|
90
|
+
code: "request_failed",
|
|
91
|
+
operation,
|
|
92
|
+
method,
|
|
93
|
+
url: requestUrl,
|
|
94
|
+
retryable: true,
|
|
95
|
+
});
|
|
96
|
+
this.emitErrorLog(normalized, "client", operation);
|
|
97
|
+
throw normalized;
|
|
98
|
+
}
|
|
99
|
+
const requestId = extractRequestId(response);
|
|
100
|
+
const text = await this.readResponseText(response, operation, method, requestUrl);
|
|
27
101
|
if (!response.ok) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
102
|
+
const parsed = text.trim() ? safeParseJsonText(text) : null;
|
|
103
|
+
const parsedBody = parsed?.ok && parsed.value && typeof parsed.value === "object"
|
|
104
|
+
? parsed.value
|
|
105
|
+
: null;
|
|
106
|
+
const message = typeof parsedBody?.error === "string" && parsedBody.error.trim()
|
|
107
|
+
? parsedBody.error
|
|
108
|
+
: text.trim() || `HTTP ${response.status}`;
|
|
109
|
+
const error = createNoMessHttpError(message, {
|
|
110
|
+
kind: "http",
|
|
111
|
+
code: "http_error",
|
|
112
|
+
status: response.status,
|
|
113
|
+
operation,
|
|
114
|
+
method,
|
|
115
|
+
url: requestUrl,
|
|
116
|
+
requestId,
|
|
117
|
+
retryable: response.status >= 500,
|
|
118
|
+
});
|
|
119
|
+
this.emitErrorLog(error, "client", operation);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
const parsed = safeParseJsonText(text);
|
|
123
|
+
if (!parsed.ok) {
|
|
124
|
+
const error = createNoMessResponseError("Received invalid JSON response", {
|
|
125
|
+
kind: "response",
|
|
126
|
+
code: "invalid_success_response",
|
|
127
|
+
operation,
|
|
128
|
+
method,
|
|
129
|
+
url: requestUrl,
|
|
130
|
+
requestId,
|
|
131
|
+
details: {
|
|
132
|
+
responseText: text.slice(0, 200),
|
|
133
|
+
},
|
|
134
|
+
cause: parsed.error,
|
|
135
|
+
});
|
|
136
|
+
this.emitErrorLog(error, "client", operation);
|
|
137
|
+
throw error;
|
|
32
138
|
}
|
|
33
|
-
return
|
|
139
|
+
return parsed.value;
|
|
34
140
|
}
|
|
35
141
|
/**
|
|
36
142
|
* List all content type schemas with fields, TypeScript interfaces, and entry counts.
|
|
37
143
|
*/
|
|
38
144
|
async getSchemas() {
|
|
39
|
-
return this.
|
|
145
|
+
return this.request({
|
|
146
|
+
method: "GET",
|
|
147
|
+
path: "/api/schema",
|
|
148
|
+
operation: "getSchemas",
|
|
149
|
+
});
|
|
40
150
|
}
|
|
41
151
|
/**
|
|
42
152
|
* Get a single content type schema by slug.
|
|
43
153
|
*/
|
|
44
154
|
async getSchema(typeSlug) {
|
|
45
|
-
return this.
|
|
155
|
+
return this.request({
|
|
156
|
+
method: "GET",
|
|
157
|
+
path: `/api/schema/${typeSlug}`,
|
|
158
|
+
operation: "getSchema",
|
|
159
|
+
});
|
|
46
160
|
}
|
|
47
161
|
/**
|
|
48
162
|
* Get all published entries of a content type.
|
|
49
163
|
*/
|
|
50
164
|
async getEntries(contentType) {
|
|
51
|
-
return this.
|
|
165
|
+
return this.request({
|
|
166
|
+
method: "GET",
|
|
167
|
+
path: `/api/content/${contentType}`,
|
|
168
|
+
operation: "getEntries",
|
|
169
|
+
});
|
|
52
170
|
}
|
|
53
171
|
/**
|
|
54
172
|
* Get a single entry by content type and slug.
|
|
@@ -62,31 +180,52 @@ export class NoMessClient {
|
|
|
62
180
|
params.secret = options.previewSecret;
|
|
63
181
|
}
|
|
64
182
|
}
|
|
65
|
-
return this.
|
|
183
|
+
return this.request({
|
|
184
|
+
method: "GET",
|
|
185
|
+
path: `/api/content/${contentType}/${slug}`,
|
|
186
|
+
params,
|
|
187
|
+
operation: "getEntry",
|
|
188
|
+
});
|
|
66
189
|
}
|
|
67
190
|
/**
|
|
68
191
|
* Get all synced Shopify products.
|
|
69
192
|
*/
|
|
70
193
|
async getProducts() {
|
|
71
|
-
return this.
|
|
194
|
+
return this.request({
|
|
195
|
+
method: "GET",
|
|
196
|
+
path: "/api/shopify/products",
|
|
197
|
+
operation: "getProducts",
|
|
198
|
+
});
|
|
72
199
|
}
|
|
73
200
|
/**
|
|
74
201
|
* Get a single Shopify product by handle.
|
|
75
202
|
*/
|
|
76
203
|
async getProduct(handle) {
|
|
77
|
-
return this.
|
|
204
|
+
return this.request({
|
|
205
|
+
method: "GET",
|
|
206
|
+
path: `/api/shopify/products/${handle}`,
|
|
207
|
+
operation: "getProduct",
|
|
208
|
+
});
|
|
78
209
|
}
|
|
79
210
|
/**
|
|
80
211
|
* Get all synced Shopify collections.
|
|
81
212
|
*/
|
|
82
213
|
async getCollections() {
|
|
83
|
-
return this.
|
|
214
|
+
return this.request({
|
|
215
|
+
method: "GET",
|
|
216
|
+
path: "/api/shopify/collections",
|
|
217
|
+
operation: "getCollections",
|
|
218
|
+
});
|
|
84
219
|
}
|
|
85
220
|
/**
|
|
86
221
|
* Get a single Shopify collection by handle.
|
|
87
222
|
*/
|
|
88
223
|
async getCollection(handle) {
|
|
89
|
-
return this.
|
|
224
|
+
return this.request({
|
|
225
|
+
method: "GET",
|
|
226
|
+
path: `/api/shopify/collections/${handle}`,
|
|
227
|
+
operation: "getCollection",
|
|
228
|
+
});
|
|
90
229
|
}
|
|
91
230
|
/**
|
|
92
231
|
* Exchange a preview session for draft content.
|
|
@@ -95,40 +234,110 @@ export class NoMessClient {
|
|
|
95
234
|
async exchangePreviewSession(session) {
|
|
96
235
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
97
236
|
const proof = await this.computeProof(session.sessionSecret, session.sessionId, timestamp);
|
|
98
|
-
|
|
237
|
+
return this.request({
|
|
99
238
|
method: "POST",
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
body: JSON.stringify({
|
|
239
|
+
path: "/api/preview/exchange",
|
|
240
|
+
operation: "exchangePreviewSession",
|
|
241
|
+
body: {
|
|
105
242
|
sessionId: session.sessionId,
|
|
106
243
|
timestamp,
|
|
107
244
|
proof,
|
|
108
|
-
}
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Report that an entry is rendered on the current site URL for route-aware live edit.
|
|
250
|
+
*/
|
|
251
|
+
async reportLiveEditRoute(options) {
|
|
252
|
+
return this.request({
|
|
253
|
+
method: "POST",
|
|
254
|
+
path: "/api/live-edit/routes/report",
|
|
255
|
+
operation: "reportLiveEditRoute",
|
|
256
|
+
body: options,
|
|
109
257
|
});
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const body = await response
|
|
112
|
-
.json()
|
|
113
|
-
.catch(() => ({ error: "Unknown error" }));
|
|
114
|
-
throw new NoMessError(body.error ?? `HTTP ${response.status}`, response.status);
|
|
115
|
-
}
|
|
116
|
-
return response.json();
|
|
117
258
|
}
|
|
118
259
|
/**
|
|
119
260
|
* Compute HMAC-SHA256 proof for preview session authentication.
|
|
120
261
|
* Uses Web Crypto API (works in browsers, Node.js 18+, Deno, Bun, edge runtimes).
|
|
121
262
|
*/
|
|
122
263
|
async computeProof(sessionSecret, sessionId, timestamp) {
|
|
264
|
+
if (!sessionSecret ||
|
|
265
|
+
sessionSecret.length % 2 !== 0 ||
|
|
266
|
+
!/^[0-9a-fA-F]+$/.test(sessionSecret)) {
|
|
267
|
+
const error = createNoMessCryptoError("Preview session secret must be a valid hex string", {
|
|
268
|
+
kind: "crypto",
|
|
269
|
+
code: "invalid_session_secret",
|
|
270
|
+
operation: "computeProof",
|
|
271
|
+
details: {
|
|
272
|
+
sessionId,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
this.emitErrorLog(error, "client", "computeProof");
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
279
|
+
const error = createNoMessCryptoError("Web Crypto API is not available in this runtime", {
|
|
280
|
+
kind: "crypto",
|
|
281
|
+
code: "crypto_unavailable",
|
|
282
|
+
operation: "computeProof",
|
|
283
|
+
details: {
|
|
284
|
+
sessionId,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
this.emitErrorLog(error, "client", "computeProof");
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
123
290
|
const secretBytes = new Uint8Array((sessionSecret.match(/.{2}/g) ?? []).map((byte) => parseInt(byte, 16)));
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
291
|
+
let key;
|
|
292
|
+
try {
|
|
293
|
+
key = await crypto.subtle.importKey("raw", secretBytes, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
const normalized = createNoMessCryptoError("Failed to initialize preview proof signing key", {
|
|
297
|
+
kind: "crypto",
|
|
298
|
+
code: "invalid_session_secret",
|
|
299
|
+
operation: "computeProof",
|
|
300
|
+
details: {
|
|
301
|
+
sessionId,
|
|
302
|
+
},
|
|
303
|
+
cause: error,
|
|
304
|
+
});
|
|
305
|
+
this.emitErrorLog(normalized, "client", "computeProof");
|
|
306
|
+
throw normalized;
|
|
307
|
+
}
|
|
127
308
|
const message = new TextEncoder().encode(`${sessionId}.${timestamp}`);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
309
|
+
try {
|
|
310
|
+
const signature = await crypto.subtle.sign("HMAC", key, message);
|
|
311
|
+
return this.toBase64(new Uint8Array(signature));
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
const normalized = createNoMessCryptoError("Failed to sign preview proof", {
|
|
315
|
+
kind: "crypto",
|
|
316
|
+
code: "crypto_unavailable",
|
|
317
|
+
operation: "computeProof",
|
|
318
|
+
details: {
|
|
319
|
+
sessionId,
|
|
320
|
+
},
|
|
321
|
+
cause: error,
|
|
322
|
+
});
|
|
323
|
+
this.emitErrorLog(normalized, "client", "computeProof");
|
|
324
|
+
throw normalized;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
toBase64(bytes) {
|
|
328
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
329
|
+
let output = "";
|
|
330
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
331
|
+
const a = bytes[index] ?? 0;
|
|
332
|
+
const b = bytes[index + 1] ?? 0;
|
|
333
|
+
const c = bytes[index + 2] ?? 0;
|
|
334
|
+
const chunk = (a << 16) | (b << 8) | c;
|
|
335
|
+
output += alphabet[(chunk >> 18) & 0x3f];
|
|
336
|
+
output += alphabet[(chunk >> 12) & 0x3f];
|
|
337
|
+
output += index + 1 < bytes.length ? alphabet[(chunk >> 6) & 0x3f] : "=";
|
|
338
|
+
output += index + 2 < bytes.length ? alphabet[chunk & 0x3f] : "=";
|
|
339
|
+
}
|
|
340
|
+
return output;
|
|
132
341
|
}
|
|
133
342
|
}
|
|
134
343
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAczD,OAAO,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAU/D,MAAM,OAAO,YAAY;IAKvB,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE7C,IACE,OAAO,MAA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AAC,IAAI,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAEvC,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACzC,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACzC,MAAM,IAAI,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACzE,MAAM,IAAI,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACpE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NoMessError, type NoMessErrorCode, type NoMessErrorKind, type NoMessErrorOptions } from "./types.js";
|
|
2
|
+
interface ErrorMetadata extends NoMessErrorOptions {
|
|
3
|
+
kind: NoMessErrorKind;
|
|
4
|
+
code: NoMessErrorCode;
|
|
5
|
+
}
|
|
6
|
+
export declare function safeParseJsonText(text: string): {
|
|
7
|
+
ok: true;
|
|
8
|
+
value: unknown;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: Error;
|
|
12
|
+
};
|
|
13
|
+
export declare function extractRequestId(response: Response): string | undefined;
|
|
14
|
+
export declare function normalizeNoMessError(input: unknown, metadata: ErrorMetadata): NoMessError;
|
|
15
|
+
export declare function createNoMessHttpError(message: string, metadata: ErrorMetadata): NoMessError;
|
|
16
|
+
export declare function createNoMessResponseError(message: string, metadata: ErrorMetadata): NoMessError;
|
|
17
|
+
export declare function createNoMessProtocolError(message: string, metadata: ErrorMetadata): NoMessError;
|
|
18
|
+
export declare function createNoMessCryptoError(message: string, metadata: ErrorMetadata): NoMessError;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=error-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../src/error-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAEpB,UAAU,aAAc,SAAQ,kBAAkB;IAChD,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAC1C;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAS9B;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAWvE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB,WAAW,CAuBb;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,GACtB,WAAW,CAMb;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,GACtB,WAAW,CAKb;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,GACtB,WAAW,CAKb;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,GACtB,WAAW,CAKb"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NoMessError, } from "./types.js";
|
|
2
|
+
export function safeParseJsonText(text) {
|
|
3
|
+
try {
|
|
4
|
+
return { ok: true, value: JSON.parse(text) };
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
return {
|
|
8
|
+
ok: false,
|
|
9
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function extractRequestId(response) {
|
|
14
|
+
try {
|
|
15
|
+
return (response.headers.get("x-request-id") ??
|
|
16
|
+
response.headers.get("cf-ray") ??
|
|
17
|
+
response.headers.get("traceparent") ??
|
|
18
|
+
undefined);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function normalizeNoMessError(input, metadata) {
|
|
25
|
+
if (input instanceof NoMessError) {
|
|
26
|
+
return input;
|
|
27
|
+
}
|
|
28
|
+
if (input instanceof Error) {
|
|
29
|
+
return new NoMessError(input.message, {
|
|
30
|
+
...metadata,
|
|
31
|
+
retryable: metadata.retryable ?? false,
|
|
32
|
+
details: { ...metadata.details, originalName: input.name },
|
|
33
|
+
cause: input,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return new NoMessError(typeof input === "string" ? input : "Unexpected error", {
|
|
37
|
+
...metadata,
|
|
38
|
+
retryable: metadata.retryable ?? false,
|
|
39
|
+
details: { ...metadata.details, originalValue: input },
|
|
40
|
+
cause: input,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function createNoMessHttpError(message, metadata) {
|
|
44
|
+
return new NoMessError(message, {
|
|
45
|
+
...metadata,
|
|
46
|
+
retryable: metadata.retryable ?? (typeof metadata.status === "number" && metadata.status >= 500),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function createNoMessResponseError(message, metadata) {
|
|
50
|
+
return new NoMessError(message, {
|
|
51
|
+
...metadata,
|
|
52
|
+
retryable: metadata.retryable ?? false,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function createNoMessProtocolError(message, metadata) {
|
|
56
|
+
return new NoMessError(message, {
|
|
57
|
+
...metadata,
|
|
58
|
+
retryable: metadata.retryable ?? false,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function createNoMessCryptoError(message, metadata) {
|
|
62
|
+
return new NoMessError(message, {
|
|
63
|
+
...metadata,
|
|
64
|
+
retryable: metadata.retryable ?? false,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.js","sourceRoot":"","sources":["../src/error-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAIZ,MAAM,YAAY,CAAC;AAOpB,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAG5C,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAkB;IACjD,IAAI,CAAC;QACH,OAAO,CACL,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;YACpC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC9B,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;YACnC,SAAS,CACV,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,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,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAAe,EACf,QAAuB;IAEvB,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE;QAC9B,GAAG,QAAQ;QACX,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,KAAK;KACvC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,OAAe,EACf,QAAuB;IAEvB,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE;QAC9B,GAAG,QAAQ;QACX,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,KAAK;KACvC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { NoMessClient } from "./client.js";
|
|
2
2
|
export { createLiveEditHandler } from "./live-edit.js";
|
|
3
|
-
export type { ContentTypeSchema, GetEntryOptions, LiveEditConfig, LiveEditHandle, NoMessClientConfig, NoMessEntry, PreviewExchangeResult, PreviewHandlerConfig, PreviewSessionAuth, SchemaGetResponse, SchemaListResponse, ShopifyCollection, ShopifyProduct, UseNoMessLiveEditConfig, UseNoMessLiveEditResult, UseNoMessPreviewConfig, UseNoMessPreviewResult, } from "./types.js";
|
|
3
|
+
export type { ContentTypeSchema, GetEntryOptions, LiveEditConfig, LiveEditHandle, NoMessClientConfig, NoMessEntry, NoMessErrorCode, NoMessErrorKind, NoMessErrorOptions, NoMessLiveRouteProviderProps, NoMessLogEvent, NoMessLogger, NoMessLogLevel, NoMessProviderProps, PreviewExchangeResult, PreviewHandlerConfig, PreviewSessionAuth, ReportLiveEditRouteOptions, SchemaGetResponse, SchemaListResponse, ShopifyCollection, ShopifyProduct, UseNoMessEditableEntryOptions, UseNoMessLiveEditConfig, UseNoMessLiveEditResult, UseNoMessPreviewConfig, UseNoMessPreviewResult, UseNoMessPreviewStatus, } from "./types.js";
|
|
4
4
|
export { DEFAULT_ADMIN_ORIGIN, DEFAULT_API_URL, isPublishableKey, isSecretKey, NoMessError, } from "./types.js";
|
|
5
5
|
import { NoMessClient } from "./client.js";
|
|
6
6
|
import type { NoMessClientConfig, PreviewHandlerConfig } from "./types.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,4BAA4B,EAC5B,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EAC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