@nemme/js-sdk 0.5.1 → 0.6.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 (48) hide show
  1. package/README.md +46 -13
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/chunks/client-CEykSZ2c.js +389 -0
  4. package/dist/chunks/client-CEykSZ2c.js.map +1 -0
  5. package/dist/chunks/client-DZJN73sh.js +2 -0
  6. package/dist/chunks/client-DZJN73sh.js.map +1 -0
  7. package/dist/chunks/form-manager-CdG9IzjD.js +12 -0
  8. package/dist/chunks/form-manager-CdG9IzjD.js.map +1 -0
  9. package/dist/chunks/form-manager-Dre89wMr.js +6143 -0
  10. package/dist/chunks/form-manager-Dre89wMr.js.map +1 -0
  11. package/dist/chunks/httpClient-D2IO92uv.js +149 -0
  12. package/dist/chunks/httpClient-D2IO92uv.js.map +1 -0
  13. package/dist/chunks/httpClient-hrn9Ffa2.js +2 -0
  14. package/dist/chunks/httpClient-hrn9Ffa2.js.map +1 -0
  15. package/dist/chunks/jsx-runtime-BubrbI3X.js +2 -0
  16. package/dist/chunks/jsx-runtime-BubrbI3X.js.map +1 -0
  17. package/dist/chunks/jsx-runtime-jIxVPx5o.js +32 -0
  18. package/dist/chunks/jsx-runtime-jIxVPx5o.js.map +1 -0
  19. package/dist/client.d.ts +2 -1
  20. package/dist/deliveries/delivery-manager.d.ts +3 -2
  21. package/dist/forms/form-manager.d.ts +1 -10
  22. package/dist/forms-entry.d.ts +3 -0
  23. package/dist/forms.cjs +2 -0
  24. package/dist/forms.cjs.map +1 -0
  25. package/dist/forms.esm.js +6 -0
  26. package/dist/forms.esm.js.map +1 -0
  27. package/dist/index.cjs +1 -46
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.esm.js +6 -6732
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/js-sdk.css +1 -0
  33. package/dist/nemme-sdk.umd.js +4 -39
  34. package/dist/nemme-sdk.umd.js.map +1 -1
  35. package/dist/react/NemmeProvider.d.ts +2 -2
  36. package/dist/react-entry.d.ts +3 -0
  37. package/dist/react.cjs +2 -0
  38. package/dist/react.cjs.map +1 -0
  39. package/dist/react.esm.js +67 -0
  40. package/dist/react.esm.js.map +1 -0
  41. package/dist/style-entry.d.ts +0 -0
  42. package/dist/style.cjs +2 -0
  43. package/dist/style.cjs.map +1 -0
  44. package/dist/style.esm.js +2 -0
  45. package/dist/style.esm.js.map +1 -0
  46. package/dist/types/forms.d.ts +10 -0
  47. package/package.json +57 -30
  48. package/dist/assets/js-sdk.css +0 -1
@@ -0,0 +1,149 @@
1
+ const T = {
2
+ apiBaseUrl: "https://api.nemme.io",
3
+ debug: !1
4
+ }, p = {
5
+ debug: 0,
6
+ info: 1,
7
+ warn: 2,
8
+ error: 3
9
+ };
10
+ class h {
11
+ prefix;
12
+ enabled;
13
+ level;
14
+ constructor(e = {}) {
15
+ this.prefix = e.prefix || "Nemme SDK", this.enabled = e.enabled !== void 0 ? e.enabled : !0, this.level = e.level || "info";
16
+ }
17
+ shouldLog(e) {
18
+ return this.enabled && p[e] >= p[this.level];
19
+ }
20
+ formatMessage(e) {
21
+ return `[${this.prefix}] ${e}`;
22
+ }
23
+ debug(e, ...t) {
24
+ this.shouldLog("debug") && console.debug(this.formatMessage(e), ...t);
25
+ }
26
+ info(e, ...t) {
27
+ this.shouldLog("info") && console.info(this.formatMessage(e), ...t);
28
+ }
29
+ warn(e, ...t) {
30
+ this.shouldLog("warn") && console.warn(this.formatMessage(e), ...t);
31
+ }
32
+ error(e, ...t) {
33
+ this.shouldLog("error") && console.error(this.formatMessage(e), ...t);
34
+ }
35
+ // Create a child logger with a new prefix
36
+ child(e) {
37
+ return new h({
38
+ prefix: `${this.prefix}:${e}`,
39
+ enabled: this.enabled,
40
+ level: this.level
41
+ });
42
+ }
43
+ // Configure logger settings
44
+ configure(e) {
45
+ e.prefix !== void 0 && (this.prefix = e.prefix), e.enabled !== void 0 && (this.enabled = e.enabled), e.level !== void 0 && (this.level = e.level);
46
+ }
47
+ }
48
+ const w = new h(), m = w.child("network"), v = 3e4, E = (r, e) => {
49
+ const t = new URL(r, T.apiBaseUrl);
50
+ return e && Object.entries(e).forEach(([d, i]) => {
51
+ i != null && t.searchParams.append(d, String(i));
52
+ }), t.toString();
53
+ }, L = {
54
+ /**
55
+ * Make an HTTP request
56
+ */
57
+ async request(r, e = {}) {
58
+ const { method: t = "GET", headers: d = {}, body: i, params: b, timeout: u = v } = e, c = E(r, b), y = {
59
+ "Content-Type": "application/json",
60
+ Accept: "application/json",
61
+ ...d
62
+ }, f = {
63
+ method: t,
64
+ headers: y,
65
+ body: i ? JSON.stringify(i) : void 0
66
+ }, g = new AbortController(), x = setTimeout(() => g.abort(), u);
67
+ f.signal = g.signal;
68
+ try {
69
+ const s = await fetch(c, f);
70
+ let o;
71
+ const a = s.headers.get("content-type");
72
+ if (a && a.includes("application/json"))
73
+ o = await s.json();
74
+ else {
75
+ const l = await s.text();
76
+ try {
77
+ o = JSON.parse(l);
78
+ } catch {
79
+ o = l;
80
+ }
81
+ }
82
+ const n = {
83
+ data: o,
84
+ status: s.status,
85
+ statusText: s.statusText,
86
+ headers: s.headers,
87
+ ok: s.ok
88
+ };
89
+ if (s.ok)
90
+ n.ok = !0;
91
+ else {
92
+ const l = `Request failed with status ${s.status}: ${s.statusText}`;
93
+ m.error(l, {
94
+ url: c,
95
+ method: t,
96
+ status: s.status,
97
+ data: n.data
98
+ }), n.ok = !1, n.error = {
99
+ message: l,
100
+ details: n.data
101
+ };
102
+ }
103
+ return n;
104
+ } catch (s) {
105
+ let o = "Network request failed", a = {};
106
+ return s instanceof DOMException && s.name === "AbortError" ? (o = `Request timeout after ${u}ms`, a = { timeout: u, url: c }) : a = {
107
+ message: s instanceof Error ? s.message : String(s),
108
+ url: c,
109
+ method: t
110
+ }, m.error(o, a), {
111
+ data: {},
112
+ status: 0,
113
+ statusText: o,
114
+ headers: new Headers(),
115
+ ok: !1,
116
+ error: {
117
+ message: o,
118
+ details: a
119
+ }
120
+ };
121
+ } finally {
122
+ clearTimeout(x);
123
+ }
124
+ },
125
+ /**
126
+ * Convenience methods for common HTTP methods
127
+ */
128
+ async get(r, e = {}) {
129
+ return this.request(r, { ...e, method: "GET" });
130
+ },
131
+ async post(r, e, t = {}) {
132
+ return this.request(r, { ...t, method: "POST", body: e });
133
+ },
134
+ async put(r, e, t = {}) {
135
+ return this.request(r, { ...t, method: "PUT", body: e });
136
+ },
137
+ async patch(r, e, t = {}) {
138
+ return this.request(r, { ...t, method: "PATCH", body: e });
139
+ },
140
+ async delete(r, e = {}) {
141
+ return this.request(r, { ...e, method: "DELETE" });
142
+ }
143
+ };
144
+ export {
145
+ T as c,
146
+ L as h,
147
+ w as l
148
+ };
149
+ //# sourceMappingURL=httpClient-D2IO92uv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient-D2IO92uv.js","sources":["../../src/config.ts","../../src/utils/logger.ts","../../src/networking/httpClient.ts"],"sourcesContent":["export const config = {\n apiBaseUrl: import.meta.env['VITE_API_BASE_URL'],\n debug: import.meta.env.DEV\n};\n","/**\n * Logger utility for the SDK\n * Provides consistent logging across the SDK with different log levels\n */\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\ninterface LoggerOptions {\n prefix?: string;\n enabled?: boolean;\n level?: LogLevel;\n}\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3\n};\n\nexport class Logger {\n private prefix: string;\n private enabled: boolean;\n private level: LogLevel;\n\n constructor(options: LoggerOptions = {}) {\n this.prefix = options.prefix || 'Nemme SDK';\n this.enabled = options.enabled !== undefined ? options.enabled : true;\n this.level = options.level || 'info';\n }\n\n private shouldLog(level: LogLevel): boolean {\n return this.enabled && LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n }\n\n private formatMessage(message: string): string {\n return `[${this.prefix}] ${message}`;\n }\n\n debug(message: string, ...args: unknown[]): void {\n if (this.shouldLog('debug')) {\n console.debug(this.formatMessage(message), ...args);\n }\n }\n\n info(message: string, ...args: unknown[]): void {\n if (this.shouldLog('info')) {\n console.info(this.formatMessage(message), ...args);\n }\n }\n\n warn(message: string, ...args: unknown[]): void {\n if (this.shouldLog('warn')) {\n console.warn(this.formatMessage(message), ...args);\n }\n }\n\n error(message: string, ...args: unknown[]): void {\n if (this.shouldLog('error')) {\n console.error(this.formatMessage(message), ...args);\n }\n }\n\n // Create a child logger with a new prefix\n child(prefix: string): Logger {\n return new Logger({\n prefix: `${this.prefix}:${prefix}`,\n enabled: this.enabled,\n level: this.level\n });\n }\n\n // Configure logger settings\n configure(options: LoggerOptions): void {\n if (options.prefix !== undefined) {\n this.prefix = options.prefix;\n }\n if (options.enabled !== undefined) {\n this.enabled = options.enabled;\n }\n if (options.level !== undefined) {\n this.level = options.level;\n }\n }\n}\n\n// Create and export a default logger instance\nexport const logger = new Logger();\n","import { config } from '../config';\nimport { logger } from '../utils';\n\n// Create a network-specific logger\nconst networkLogger = logger.child('network');\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\nexport interface RequestOptions {\n method?: HttpMethod;\n headers?: Record<string, string>;\n body?: unknown;\n params?: Record<string, string | number | boolean>;\n timeout?: number;\n}\n\nexport interface HttpResponse<T = unknown> {\n data: T;\n status: number;\n statusText: string;\n headers: Headers;\n ok: boolean;\n error?: {\n message: string;\n details?: unknown;\n };\n}\n\nconst DEFAULT_TIMEOUT = 30000; // 30 seconds\n\n/**\n * Creates a URL with query parameters\n */\nconst createUrl = (endpoint: string, params?: Record<string, string | number | boolean>): string => {\n const url = new URL(endpoint, config.apiBaseUrl);\n\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n};\n\n/**\n * Global HTTP client for making API requests\n */\nexport const httpClient = {\n /**\n * Make an HTTP request\n */\n async request<T = unknown>(endpoint: string, options: RequestOptions = {}): Promise<HttpResponse<T>> {\n const { method = 'GET', headers = {}, body, params, timeout = DEFAULT_TIMEOUT } = options;\n\n const url = createUrl(endpoint, params);\n\n // Prepare headers with defaults\n const requestHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...headers\n };\n\n // Prepare request options\n const requestOptions: RequestInit = {\n method,\n headers: requestHeaders,\n body: body ? JSON.stringify(body) : undefined\n };\n\n // Create abort controller for timeout\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n requestOptions.signal = controller.signal;\n\n try {\n const response = await fetch(url, requestOptions);\n\n // Parse response data\n let data: T;\n const contentType = response.headers.get('content-type');\n\n if (contentType && contentType.includes('application/json')) {\n data = await response.json();\n } else {\n const text = await response.text();\n try {\n data = JSON.parse(text) as T;\n } catch {\n data = text as unknown as T;\n }\n }\n\n const result: HttpResponse<T> = {\n data,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n ok: response.ok\n };\n\n // Handle error responses but don't throw\n if (!response.ok) {\n const errorMessage = `Request failed with status ${response.status}: ${response.statusText}`;\n networkLogger.error(errorMessage, {\n url,\n method,\n status: response.status,\n data: result.data\n });\n\n result.ok = false;\n result.error = {\n message: errorMessage,\n details: result.data\n };\n } else {\n result.ok = true;\n }\n\n return result;\n } catch (error) {\n // Log the error but don't throw\n let errorMessage = 'Network request failed';\n let errorDetails = {};\n\n if (error instanceof DOMException && error.name === 'AbortError') {\n errorMessage = `Request timeout after ${timeout}ms`;\n errorDetails = { timeout, url };\n } else {\n errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n url,\n method\n };\n }\n\n networkLogger.error(errorMessage, errorDetails);\n\n // Return an error response instead of throwing\n const errorResponse: HttpResponse<T> = {\n data: {} as T,\n status: 0,\n statusText: errorMessage,\n headers: new Headers(),\n ok: false,\n error: {\n message: errorMessage,\n details: errorDetails\n }\n };\n\n return errorResponse;\n } finally {\n clearTimeout(timeoutId);\n }\n },\n\n /**\n * Convenience methods for common HTTP methods\n */\n async get<T = unknown>(endpoint: string, options: Omit<RequestOptions, 'method'> = {}): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'GET' });\n },\n\n async post<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'POST', body: data });\n },\n\n async put<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'PUT', body: data });\n },\n\n async patch<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'PATCH', body: data });\n },\n\n async delete<T = unknown>(endpoint: string, options: Omit<RequestOptions, 'method'> = {}): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'DELETE' });\n }\n};\n"],"names":["config","LOG_LEVELS","Logger","options","level","message","args","prefix","logger","networkLogger","DEFAULT_TIMEOUT","createUrl","endpoint","params","url","key","value","httpClient","method","headers","body","timeout","requestHeaders","requestOptions","controller","timeoutId","response","data","contentType","text","result","errorMessage","error","errorDetails"],"mappings":"AAAO,MAAMA,IAAS;AAAA,EACpB,YAAY;AAAA,EACZ,OAAO;AACT,GCUMC,IAAuC;AAAA,EAC3C,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAEO,MAAMC,EAAO;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAYC,IAAyB,IAAI;AACvC,SAAK,SAASA,EAAQ,UAAU,aAChC,KAAK,UAAUA,EAAQ,YAAY,SAAYA,EAAQ,UAAU,IACjE,KAAK,QAAQA,EAAQ,SAAS;AAAA,EAChC;AAAA,EAEQ,UAAUC,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B,WAAO,KAAK,QAAWS,GAAU,EAAE,GAAGT,GAAS,QAAQ,QAAQ,MAAMwB,GAAM;AAAA,EAC7E;AAAA,EAEA,MAAM,IACJf,GACAe,GACAxB,IAAmD,CAAA,GACzB;AAC1B,WAAO,KAAK,QAAWS,GAAU,EAAE,GAAGT,GAAS,QAAQ,OAAO,MAAMwB,GAAM;AAAA,EAC5E;AAAA,EAEA,MAAM,MACJf,GACAe,GACAxB,IAAmD,CAAA,GACzB;AAC1B,WAAO,KAAK,QAAWS,GAAU,EAAE,GAAGT,GAAS,QAAQ,SAAS,MAAMwB,GAAM;AAAA,EAC9E;AAAA,EAEA,MAAM,OAAoBf,GAAkBT,IAA0C,IAA8B;AAClH,WAAO,KAAK,QAAWS,GAAU,EAAE,GAAGT,GAAS,QAAQ,UAAU;AAAA,EACnE;AACF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const b={apiBaseUrl:"https://api.nemme.io",debug:!1},p={debug:0,info:1,warn:2,error:3};class h{prefix;enabled;level;constructor(e={}){this.prefix=e.prefix||"Nemme SDK",this.enabled=e.enabled!==void 0?e.enabled:!0,this.level=e.level||"info"}shouldLog(e){return this.enabled&&p[e]>=p[this.level]}formatMessage(e){return`[${this.prefix}] ${e}`}debug(e,...t){this.shouldLog("debug")&&console.debug(this.formatMessage(e),...t)}info(e,...t){this.shouldLog("info")&&console.info(this.formatMessage(e),...t)}warn(e,...t){this.shouldLog("warn")&&console.warn(this.formatMessage(e),...t)}error(e,...t){this.shouldLog("error")&&console.error(this.formatMessage(e),...t)}child(e){return new h({prefix:`${this.prefix}:${e}`,enabled:this.enabled,level:this.level})}configure(e){e.prefix!==void 0&&(this.prefix=e.prefix),e.enabled!==void 0&&(this.enabled=e.enabled),e.level!==void 0&&(this.level=e.level)}}const y=new h,m=y.child("network"),v=3e4,E=(r,e)=>{const t=new URL(r,b.apiBaseUrl);return e&&Object.entries(e).forEach(([d,i])=>{i!=null&&t.searchParams.append(d,String(i))}),t.toString()},L={async request(r,e={}){const{method:t="GET",headers:d={},body:i,params:T,timeout:u=v}=e,c=E(r,T),w={"Content-Type":"application/json",Accept:"application/json",...d},f={method:t,headers:w,body:i?JSON.stringify(i):void 0},g=new AbortController,x=setTimeout(()=>g.abort(),u);f.signal=g.signal;try{const s=await fetch(c,f);let o;const a=s.headers.get("content-type");if(a&&a.includes("application/json"))o=await s.json();else{const l=await s.text();try{o=JSON.parse(l)}catch{o=l}}const n={data:o,status:s.status,statusText:s.statusText,headers:s.headers,ok:s.ok};if(s.ok)n.ok=!0;else{const l=`Request failed with status ${s.status}: ${s.statusText}`;m.error(l,{url:c,method:t,status:s.status,data:n.data}),n.ok=!1,n.error={message:l,details:n.data}}return n}catch(s){let o="Network request failed",a={};return s instanceof DOMException&&s.name==="AbortError"?(o=`Request timeout after ${u}ms`,a={timeout:u,url:c}):a={message:s instanceof Error?s.message:String(s),url:c,method:t},m.error(o,a),{data:{},status:0,statusText:o,headers:new Headers,ok:!1,error:{message:o,details:a}}}finally{clearTimeout(x)}},async get(r,e={}){return this.request(r,{...e,method:"GET"})},async post(r,e,t={}){return this.request(r,{...t,method:"POST",body:e})},async put(r,e,t={}){return this.request(r,{...t,method:"PUT",body:e})},async patch(r,e,t={}){return this.request(r,{...t,method:"PATCH",body:e})},async delete(r,e={}){return this.request(r,{...e,method:"DELETE"})}};exports.config=b;exports.httpClient=L;exports.logger=y;
2
+ //# sourceMappingURL=httpClient-hrn9Ffa2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient-hrn9Ffa2.js","sources":["../../src/config.ts","../../src/utils/logger.ts","../../src/networking/httpClient.ts"],"sourcesContent":["export const config = {\n apiBaseUrl: import.meta.env['VITE_API_BASE_URL'],\n debug: import.meta.env.DEV\n};\n","/**\n * Logger utility for the SDK\n * Provides consistent logging across the SDK with different log levels\n */\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\ninterface LoggerOptions {\n prefix?: string;\n enabled?: boolean;\n level?: LogLevel;\n}\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3\n};\n\nexport class Logger {\n private prefix: string;\n private enabled: boolean;\n private level: LogLevel;\n\n constructor(options: LoggerOptions = {}) {\n this.prefix = options.prefix || 'Nemme SDK';\n this.enabled = options.enabled !== undefined ? options.enabled : true;\n this.level = options.level || 'info';\n }\n\n private shouldLog(level: LogLevel): boolean {\n return this.enabled && LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n }\n\n private formatMessage(message: string): string {\n return `[${this.prefix}] ${message}`;\n }\n\n debug(message: string, ...args: unknown[]): void {\n if (this.shouldLog('debug')) {\n console.debug(this.formatMessage(message), ...args);\n }\n }\n\n info(message: string, ...args: unknown[]): void {\n if (this.shouldLog('info')) {\n console.info(this.formatMessage(message), ...args);\n }\n }\n\n warn(message: string, ...args: unknown[]): void {\n if (this.shouldLog('warn')) {\n console.warn(this.formatMessage(message), ...args);\n }\n }\n\n error(message: string, ...args: unknown[]): void {\n if (this.shouldLog('error')) {\n console.error(this.formatMessage(message), ...args);\n }\n }\n\n // Create a child logger with a new prefix\n child(prefix: string): Logger {\n return new Logger({\n prefix: `${this.prefix}:${prefix}`,\n enabled: this.enabled,\n level: this.level\n });\n }\n\n // Configure logger settings\n configure(options: LoggerOptions): void {\n if (options.prefix !== undefined) {\n this.prefix = options.prefix;\n }\n if (options.enabled !== undefined) {\n this.enabled = options.enabled;\n }\n if (options.level !== undefined) {\n this.level = options.level;\n }\n }\n}\n\n// Create and export a default logger instance\nexport const logger = new Logger();\n","import { config } from '../config';\nimport { logger } from '../utils';\n\n// Create a network-specific logger\nconst networkLogger = logger.child('network');\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\nexport interface RequestOptions {\n method?: HttpMethod;\n headers?: Record<string, string>;\n body?: unknown;\n params?: Record<string, string | number | boolean>;\n timeout?: number;\n}\n\nexport interface HttpResponse<T = unknown> {\n data: T;\n status: number;\n statusText: string;\n headers: Headers;\n ok: boolean;\n error?: {\n message: string;\n details?: unknown;\n };\n}\n\nconst DEFAULT_TIMEOUT = 30000; // 30 seconds\n\n/**\n * Creates a URL with query parameters\n */\nconst createUrl = (endpoint: string, params?: Record<string, string | number | boolean>): string => {\n const url = new URL(endpoint, config.apiBaseUrl);\n\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n};\n\n/**\n * Global HTTP client for making API requests\n */\nexport const httpClient = {\n /**\n * Make an HTTP request\n */\n async request<T = unknown>(endpoint: string, options: RequestOptions = {}): Promise<HttpResponse<T>> {\n const { method = 'GET', headers = {}, body, params, timeout = DEFAULT_TIMEOUT } = options;\n\n const url = createUrl(endpoint, params);\n\n // Prepare headers with defaults\n const requestHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...headers\n };\n\n // Prepare request options\n const requestOptions: RequestInit = {\n method,\n headers: requestHeaders,\n body: body ? JSON.stringify(body) : undefined\n };\n\n // Create abort controller for timeout\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n requestOptions.signal = controller.signal;\n\n try {\n const response = await fetch(url, requestOptions);\n\n // Parse response data\n let data: T;\n const contentType = response.headers.get('content-type');\n\n if (contentType && contentType.includes('application/json')) {\n data = await response.json();\n } else {\n const text = await response.text();\n try {\n data = JSON.parse(text) as T;\n } catch {\n data = text as unknown as T;\n }\n }\n\n const result: HttpResponse<T> = {\n data,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n ok: response.ok\n };\n\n // Handle error responses but don't throw\n if (!response.ok) {\n const errorMessage = `Request failed with status ${response.status}: ${response.statusText}`;\n networkLogger.error(errorMessage, {\n url,\n method,\n status: response.status,\n data: result.data\n });\n\n result.ok = false;\n result.error = {\n message: errorMessage,\n details: result.data\n };\n } else {\n result.ok = true;\n }\n\n return result;\n } catch (error) {\n // Log the error but don't throw\n let errorMessage = 'Network request failed';\n let errorDetails = {};\n\n if (error instanceof DOMException && error.name === 'AbortError') {\n errorMessage = `Request timeout after ${timeout}ms`;\n errorDetails = { timeout, url };\n } else {\n errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n url,\n method\n };\n }\n\n networkLogger.error(errorMessage, errorDetails);\n\n // Return an error response instead of throwing\n const errorResponse: HttpResponse<T> = {\n data: {} as T,\n status: 0,\n statusText: errorMessage,\n headers: new Headers(),\n ok: false,\n error: {\n message: errorMessage,\n details: errorDetails\n }\n };\n\n return errorResponse;\n } finally {\n clearTimeout(timeoutId);\n }\n },\n\n /**\n * Convenience methods for common HTTP methods\n */\n async get<T = unknown>(endpoint: string, options: Omit<RequestOptions, 'method'> = {}): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'GET' });\n },\n\n async post<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'POST', body: data });\n },\n\n async put<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'PUT', body: data });\n },\n\n async patch<T = unknown>(\n endpoint: string,\n data?: unknown,\n options: Omit<RequestOptions, 'method' | 'body'> = {}\n ): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'PATCH', body: data });\n },\n\n async delete<T = unknown>(endpoint: string, options: Omit<RequestOptions, 'method'> = {}): Promise<HttpResponse<T>> {\n return this.request<T>(endpoint, { ...options, method: 'DELETE' });\n }\n};\n"],"names":["config","LOG_LEVELS","Logger","options","level","message","args","prefix","logger","networkLogger","DEFAULT_TIMEOUT","createUrl","endpoint","params","url","key","value","httpClient","method","headers","body","timeout","requestHeaders","requestOptions","controller","timeoutId","response","data","contentType","text","result","errorMessage","error","errorDetails"],"mappings":"aAAO,MA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,EACzB,CAC1B,OAAO,KAAK,QAAWS,EAAU,CAAE,GAAGT,EAAS,OAAQ,QAAS,KAAMwB,EAAM,CAC9E,EAEA,MAAM,OAAoBf,EAAkBT,EAA0C,GAA8B,CAClH,OAAO,KAAK,QAAWS,EAAU,CAAE,GAAGT,EAAS,OAAQ,SAAU,CACnE,CACF"}
@@ -0,0 +1,2 @@
1
+ "use strict";var n={exports:{}},e={};var o;function E(){if(o)return e;o=1;var R=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function i(v,r,t){var u=null;if(t!==void 0&&(u=""+t),r.key!==void 0&&(u=""+r.key),"key"in r){t={};for(var s in r)s!=="key"&&(t[s]=r[s])}else t=r;return r=t.ref,{$$typeof:R,type:v,key:u,ref:r!==void 0?r:null,props:t}}return e.Fragment=a,e.jsx=i,e.jsxs=i,e}var x;function d(){return x||(x=1,n.exports=E()),n.exports}var l=d();exports.jsxRuntimeExports=l;
2
+ //# sourceMappingURL=jsx-runtime-BubrbI3X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime-BubrbI3X.js","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.js","../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\");\nfunction jsxProd(type, config, maybeKey) {\n var key = null;\n void 0 !== maybeKey && (key = \"\" + maybeKey);\n void 0 !== config.key && (key = \"\" + config.key);\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n config = maybeKey.ref;\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n ref: void 0 !== config ? config : null,\n props: maybeKey\n };\n}\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsxProd;\nexports.jsxs = jsxProd;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["REACT_ELEMENT_TYPE","REACT_FRAGMENT_TYPE","jsxProd","type","config","maybeKey","key","propName","reactJsxRuntime_production","jsxRuntimeModule","require$$0"],"mappings":"0EAWA,IAAIA,EAAqB,OAAO,IAAI,4BAA4B,EAC9DC,EAAsB,OAAO,IAAI,gBAAgB,EACnD,SAASC,EAAQC,EAAMC,EAAQC,EAAU,CACvC,IAAIC,EAAM,KAGV,GAFWD,IAAX,SAAwBC,EAAM,GAAKD,GACxBD,EAAO,MAAlB,SAA0BE,EAAM,GAAKF,EAAO,KACxC,QAASA,EAAQ,CACnBC,EAAW,CAAA,EACX,QAASE,KAAYH,EACTG,IAAV,QAAuBF,EAASE,CAAQ,EAAIH,EAAOG,CAAQ,EACjE,MAASF,EAAWD,EAClB,OAAAA,EAASC,EAAS,IACX,CACL,SAAUL,EACV,KAAMG,EACN,IAAKG,EACL,IAAgBF,IAAX,OAAoBA,EAAS,KAClC,MAAOC,EAEX,CACA,OAAAG,EAAA,SAAmBP,EACnBO,EAAA,IAAcN,EACdM,EAAA,KAAeN,sCC9BbO,EAAA,QAAiBC,EAAA","x_google_ignoreList":[0,1]}
@@ -0,0 +1,32 @@
1
+ var s = { exports: {} }, e = {};
2
+ var o;
3
+ function d() {
4
+ if (o) return e;
5
+ o = 1;
6
+ var R = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
7
+ function i(v, r, t) {
8
+ var u = null;
9
+ if (t !== void 0 && (u = "" + t), r.key !== void 0 && (u = "" + r.key), "key" in r) {
10
+ t = {};
11
+ for (var n in r)
12
+ n !== "key" && (t[n] = r[n]);
13
+ } else t = r;
14
+ return r = t.ref, {
15
+ $$typeof: R,
16
+ type: v,
17
+ key: u,
18
+ ref: r !== void 0 ? r : null,
19
+ props: t
20
+ };
21
+ }
22
+ return e.Fragment = a, e.jsx = i, e.jsxs = i, e;
23
+ }
24
+ var x;
25
+ function l() {
26
+ return x || (x = 1, s.exports = d()), s.exports;
27
+ }
28
+ var p = l();
29
+ export {
30
+ p as j
31
+ };
32
+ //# sourceMappingURL=jsx-runtime-jIxVPx5o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime-jIxVPx5o.js","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.js","../../../node_modules/react/jsx-runtime.js"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\");\nfunction jsxProd(type, config, maybeKey) {\n var key = null;\n void 0 !== maybeKey && (key = \"\" + maybeKey);\n void 0 !== config.key && (key = \"\" + config.key);\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n config = maybeKey.ref;\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n ref: void 0 !== config ? config : null,\n props: maybeKey\n };\n}\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsxProd;\nexports.jsxs = jsxProd;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n"],"names":["REACT_ELEMENT_TYPE","REACT_FRAGMENT_TYPE","jsxProd","type","config","maybeKey","key","propName","reactJsxRuntime_production","jsxRuntimeModule","require$$0"],"mappings":";;;;;AAWA,MAAIA,IAAqB,uBAAO,IAAI,4BAA4B,GAC9DC,IAAsB,uBAAO,IAAI,gBAAgB;AACnD,WAASC,EAAQC,GAAMC,GAAQC,GAAU;AACvC,QAAIC,IAAM;AAGV,QAFWD,MAAX,WAAwBC,IAAM,KAAKD,IACxBD,EAAO,QAAlB,WAA0BE,IAAM,KAAKF,EAAO,MACxC,SAASA,GAAQ;AACnB,MAAAC,IAAW,CAAA;AACX,eAASE,KAAYH;AACnB,QAAUG,MAAV,UAAuBF,EAASE,CAAQ,IAAIH,EAAOG,CAAQ;AAAA,IACjE,MAAS,CAAAF,IAAWD;AAClB,WAAAA,IAASC,EAAS,KACX;AAAA,MACL,UAAUL;AAAA,MACV,MAAMG;AAAA,MACN,KAAKG;AAAA,MACL,KAAgBF,MAAX,SAAoBA,IAAS;AAAA,MAClC,OAAOC;AAAA;EAEX;AACA,SAAAG,EAAA,WAAmBP,GACnBO,EAAA,MAAcN,GACdM,EAAA,OAAeN;;;;sBC9BbO,EAAA,UAAiBC,EAAA;;;","x_google_ignoreList":[0,1]}
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { FormConfig } from './forms/form-manager';
2
1
  import { BatchConfig, TrackEventOptions } from './tracking/tracking-manager';
2
+ import { FormConfig } from './types/forms';
3
3
  import { Logger } from './utils';
4
4
  export type ClientConfigType = {
5
5
  userIdentifier: string;
@@ -18,6 +18,7 @@ export declare class NemmeClient {
18
18
  clientKey: string;
19
19
  userIdentifier?: string;
20
20
  initialized: boolean;
21
+ lastInitError: Error | null;
21
22
  clientLogger: Logger;
22
23
  headers: Record<string, string>;
23
24
  formConfig?: FormConfig;
@@ -1,4 +1,4 @@
1
- import { FormConfig } from '../forms/form-manager';
1
+ import { FormConfig } from '../types/forms';
2
2
  import { Logger } from '../utils';
3
3
  export type ProductType = 'FRM' | 'TRK';
4
4
  export type Trigger = {
@@ -38,7 +38,8 @@ export type TriggerContext = {
38
38
  export declare class DeliveryManager {
39
39
  private logger;
40
40
  private headers;
41
- private formManager;
41
+ private formConfig?;
42
+ private formManager?;
42
43
  private deliveries;
43
44
  constructor(logger: Logger, headers: Record<string, string>, formConfig?: FormConfig);
44
45
  loadDeliveries(): Promise<void>;
@@ -1,15 +1,6 @@
1
+ import { FormConfig } from '../types/forms';
1
2
  import { Logger } from '../utils';
2
3
  import { FormState } from './form-wrapper/form-wrapper';
3
- export type FormErrorType = 'FETCH_ERROR' | 'SUBMISSION_ERROR';
4
- export declare class FormError extends Error {
5
- errorType: string;
6
- constructor(errorType: FormErrorType, message?: string);
7
- }
8
- export type FormConfig = {
9
- zIndex?: number;
10
- theme?: 'light' | 'dark';
11
- onFormError?: (error: FormError) => void;
12
- };
13
4
  export type FormResponse = {
14
5
  id: number;
15
6
  questions: QuestionResponse[];
@@ -0,0 +1,3 @@
1
+ export { FormManager } from './forms/form-manager';
2
+ export type { FormConfig } from './types/forms';
3
+ export { FormError } from './types/forms';
package/dist/forms.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chunks/form-manager-CdG9IzjD.js");exports.FormError=r.FormError;exports.FormManager=r.FormManager;
2
+ //# sourceMappingURL=forms.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { F as o, a as m } from "./chunks/form-manager-Dre89wMr.js";
2
+ export {
3
+ o as FormError,
4
+ m as FormManager
5
+ };
6
+ //# sourceMappingURL=forms.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}