@lumeweb/portal-sdk 0.1.0 → 0.1.1

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 (49) hide show
  1. package/dist/esm/account/generated/accountAPI.schemas.d.ts +427 -20
  2. package/dist/esm/account/generated/billing.d.ts +688 -0
  3. package/dist/esm/account/generated/billing.js +444 -0
  4. package/dist/esm/account/generated/billing.js.map +1 -0
  5. package/dist/esm/account/generated/default.d.ts +118 -97
  6. package/dist/esm/account/generated/default.js +181 -41
  7. package/dist/esm/account/generated/default.js.map +1 -1
  8. package/dist/esm/account/generated/index.d.ts +3 -3
  9. package/dist/esm/account/generated/index.js +2 -2
  10. package/dist/esm/account/generated/quota.d.ts +35 -0
  11. package/dist/esm/account/generated/quota.js +28 -0
  12. package/dist/esm/account/generated/quota.js.map +1 -0
  13. package/dist/esm/account.d.ts +0 -1
  14. package/dist/esm/account.js.map +1 -1
  15. package/dist/esm/http-utils.d.ts +0 -1
  16. package/dist/esm/http-utils.js.map +1 -1
  17. package/dist/esm/index.d.ts +5 -3
  18. package/dist/esm/index.js +4 -2
  19. package/dist/esm/openapi.d.ts +3 -3
  20. package/dist/esm/openapi.js +2 -2
  21. package/dist/esm/query-utils.d.ts +0 -1
  22. package/dist/esm/types.js.map +1 -1
  23. package/package.json +5 -5
  24. package/dist/cjs/account/generated/accountAPI.schemas.cjs +0 -0
  25. package/dist/cjs/account/generated/accountAPI.schemas.d.cts +0 -239
  26. package/dist/cjs/account/generated/default.cjs +0 -676
  27. package/dist/cjs/account/generated/default.cjs.map +0 -1
  28. package/dist/cjs/account/generated/default.d.cts +0 -923
  29. package/dist/cjs/account/generated/index.cjs +0 -58
  30. package/dist/cjs/account/generated/index.d.cts +0 -3
  31. package/dist/cjs/account.cjs +0 -348
  32. package/dist/cjs/account.cjs.map +0 -1
  33. package/dist/cjs/account.d.cts +0 -200
  34. package/dist/cjs/http-utils.cjs +0 -87
  35. package/dist/cjs/http-utils.cjs.map +0 -1
  36. package/dist/cjs/http-utils.d.cts +0 -54
  37. package/dist/cjs/index.cjs +0 -75
  38. package/dist/cjs/index.d.cts +0 -8
  39. package/dist/cjs/openapi.cjs +0 -58
  40. package/dist/cjs/openapi.d.cts +0 -3
  41. package/dist/cjs/query-utils.cjs +0 -44
  42. package/dist/cjs/query-utils.cjs.map +0 -1
  43. package/dist/cjs/query-utils.d.cts +0 -65
  44. package/dist/cjs/sdk.cjs +0 -20
  45. package/dist/cjs/sdk.cjs.map +0 -1
  46. package/dist/cjs/sdk.d.cts +0 -12
  47. package/dist/cjs/types.cjs +0 -116
  48. package/dist/cjs/types.cjs.map +0 -1
  49. package/dist/cjs/types.d.cts +0 -58
@@ -1,65 +0,0 @@
1
- import { SerializeInput } from "@lumeweb/query-builder";
2
-
3
- //#region src/query-utils.d.ts
4
-
5
- /**
6
- * Operations query parameters for the operations API
7
- *
8
- * Uses query-builder helpers to construct the API query parameters:
9
- * - filters: Array of filter objects → serialized to filters[field][operator]=value
10
- * - sorters: Array of sort objects → serialized to _sort=field&_order=direction
11
- * - pagination: Object with start/end → serialized to _start=0&_end=20
12
- * - search: Search term → passed directly as search=value
13
- *
14
- * @example
15
- * ```ts
16
- * const params: OperationsQueryParams = {
17
- * filters: [
18
- * { field: "status", operator: "eq", value: "completed" },
19
- * { field: "operation", operator: "in", value: ["upload", "download"] }
20
- * ],
21
- * sorters: [{ field: "id", order: "desc" }],
22
- * pagination: { start: 0, end: 20, page: 1, pageSize: 20 },
23
- * search: "myfile"
24
- * };
25
- * ```
26
- */
27
- interface OperationsQueryParams extends SerializeInput {
28
- /** Search term for filename or other relevant operation data */
29
- search?: string;
30
- }
31
- /**
32
- * Unified operations query parameters
33
- */
34
- type OperationsListParams = OperationsQueryParams;
35
- /**
36
- * Builds URL query parameters for operations API
37
- *
38
- * Serializes query-builder parameters to the API's expected format:
39
- * - filters → filters[field][operator]=value
40
- * - sorters → _sort=field&_order=direction
41
- * - pagination → _start=0&_end=20
42
- * - search → search=value
43
- *
44
- * @param params - Query parameters using query-builder helpers
45
- * @returns URLSearchParams object ready to use with fetch
46
- *
47
- * @example
48
- * ```ts
49
- * const searchParams = buildOperationsQueryParams({
50
- * filters: [
51
- * { field: "status", operator: "eq", value: "completed" },
52
- * { field: "operation", operator: "in", value: ["upload", "download"] }
53
- * ],
54
- * sorters: [{ field: "id", order: "desc" }],
55
- * pagination: { start: 0, end: 20, page: 1, pageSize: 20 },
56
- * search: "myfile"
57
- * });
58
- *
59
- * // Result URL: ?filters[status][eq]=completed&filters[operation][in][0]=upload&filters[operation][in][1]=download&_sort=id&_order=desc&_start=0&_end=20&search=myfile
60
- * ```
61
- */
62
- declare function buildOperationsQueryParams(params: OperationsQueryParams): URLSearchParams;
63
- //#endregion
64
- export { OperationsListParams, OperationsQueryParams, buildOperationsQueryParams };
65
- //# sourceMappingURL=query-utils.d.cts.map
package/dist/cjs/sdk.cjs DELETED
@@ -1,20 +0,0 @@
1
- const require_account = require('./account.cjs');
2
-
3
- //#region src/sdk.ts
4
- var Sdk = class {
5
- accountApi;
6
- constructor(apiUrl) {
7
- if (!apiUrl) throw new Error("API URL is required");
8
- this.accountApi = new require_account.AccountApi(apiUrl);
9
- }
10
- account() {
11
- return this.accountApi;
12
- }
13
- setAuthToken(token) {
14
- this.accountApi.setToken(token);
15
- }
16
- };
17
-
18
- //#endregion
19
- exports.Sdk = Sdk;
20
- //# sourceMappingURL=sdk.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk.cjs","names":["AccountApi"],"sources":["../../src/sdk.ts"],"sourcesContent":["import { AccountApi } from \"@/account\";\n\nexport class Sdk {\n private readonly accountApi: AccountApi;\n\n constructor(apiUrl: string) {\n if (!apiUrl) throw new Error(\"API URL is required\");\n this.accountApi = new AccountApi(apiUrl);\n }\n\n public account(): AccountApi {\n return this.accountApi;\n }\n\n public setAuthToken(token: string): void {\n this.accountApi.setToken(token);\n }\n}\n"],"mappings":";;;AAEA,IAAa,MAAb,MAAiB;CACf,AAAiB;CAEjB,YAAY,QAAgB;AAC1B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sBAAsB;AACnD,OAAK,aAAa,IAAIA,2BAAW,OAAO;;CAG1C,AAAO,UAAsB;AAC3B,SAAO,KAAK;;CAGd,AAAO,aAAa,OAAqB;AACvC,OAAK,WAAW,SAAS,MAAM"}
@@ -1,12 +0,0 @@
1
- import { AccountApi } from "./account.cjs";
2
-
3
- //#region src/sdk.d.ts
4
- declare class Sdk {
5
- private readonly accountApi;
6
- constructor(apiUrl: string);
7
- account(): AccountApi;
8
- setAuthToken(token: string): void;
9
- }
10
- //#endregion
11
- export { Sdk };
12
- //# sourceMappingURL=sdk.d.cts.map
@@ -1,116 +0,0 @@
1
- const require_http_utils = require('./http-utils.cjs');
2
-
3
- //#region src/types.ts
4
- /**
5
- * Standard error type for account-related operations
6
- */
7
- var AccountError = class extends Error {
8
- details;
9
- fields;
10
- constructor(message, statusCode, details, fields) {
11
- super(message);
12
- this.statusCode = statusCode;
13
- this.name = "AccountError";
14
- this.details = details;
15
- this.fields = fields;
16
- }
17
- toJSON() {
18
- return {
19
- details: this.details,
20
- fields: this.fields,
21
- message: this.message,
22
- statusCode: this.statusCode
23
- };
24
- }
25
- };
26
- /**
27
- * Helper function to normalize field values
28
- */
29
- function normalizeFields(fields) {
30
- if (!fields) return void 0;
31
- const normalized = {};
32
- for (const [key, value] of Object.entries(fields)) if (Array.isArray(value)) normalized[key] = value.join(", ");
33
- else if (value === null || value === void 0) normalized[key] = "";
34
- else if (typeof value === "object") normalized[key] = JSON.stringify(value);
35
- else normalized[key] = String(value);
36
- return normalized;
37
- }
38
- /**
39
- * Extract error details from a response JSON object
40
- */
41
- function extractErrorDetails(data) {
42
- let result = {
43
- message: "",
44
- details: void 0,
45
- fields: void 0
46
- };
47
- if (data?.error) {
48
- if (typeof data.error === "string") result.message = data.error;
49
- else if (data.error?.message) {
50
- result.message = data.error.message;
51
- result.details = data.error.details;
52
- result.fields = normalizeFields(data.error.fields);
53
- }
54
- } else if (data?.message) {
55
- result.message = data.message;
56
- result.details = data.details;
57
- result.fields = normalizeFields(data.fields);
58
- } else result.message = JSON.stringify(data);
59
- if (!result.fields) result.fields = normalizeFields(data?.fields) || normalizeFields(data?.error?.fields);
60
- return result;
61
- }
62
- /**
63
- * Convert a failed fetch Response to an AccountError
64
- * @param response The failed Response object
65
- * @returns A properly formatted AccountError
66
- */
67
- async function handleFetchError(response) {
68
- try {
69
- const isJson = response.headers.get("content-type")?.toLowerCase()?.includes("json");
70
- const clone = response.clone();
71
- let errorData;
72
- if (isJson) try {
73
- errorData = await response.json();
74
- } catch {
75
- errorData = await clone.text().catch(() => "") || response.statusText;
76
- }
77
- else {
78
- errorData = await response.text();
79
- if (!errorData) errorData = response.statusText;
80
- }
81
- const { message, details, fields } = typeof errorData === "string" ? { message: errorData } : extractErrorDetails(errorData);
82
- return new AccountError(message || "Unknown error", response.status, details, fields);
83
- } catch (e) {
84
- return new AccountError(response.statusText || "Unknown error", response.status, { cause: e });
85
- }
86
- }
87
- /**
88
- * Convert an unknown error to an AccountError
89
- * @param e The unknown error
90
- * @returns A properly formatted AccountError
91
- */
92
- function handleUnknownError(e) {
93
- if (e instanceof AccountError) return e;
94
- if (e instanceof Error) return new AccountError(e.message, 500, { cause: e });
95
- if (typeof e === "object" && e !== null) {
96
- let msg;
97
- try {
98
- msg = JSON.stringify(e);
99
- } catch {
100
- msg = String(e);
101
- }
102
- return new AccountError(msg, 500, { cause: e });
103
- }
104
- return new AccountError(String(e), 500);
105
- }
106
-
107
- //#endregion
108
- exports.AccountError = AccountError;
109
- exports.delay = require_http_utils.delay;
110
- exports.fetchWithHandling = require_http_utils.fetchWithHandling;
111
- exports.handleFetchError = handleFetchError;
112
- exports.handleUnknownError = handleUnknownError;
113
- exports.isEmptyResponse = require_http_utils.isEmptyResponse;
114
- exports.parseResponse = require_http_utils.parseResponse;
115
- exports.poll = require_http_utils.poll;
116
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/types.ts"],"sourcesContent":["export interface RequestInit extends Omit<globalThis.RequestInit, \"headers\"> {\n headers?: Record<string, string>;\n}\n\n/**\n * Generic Result type for consistent error handling\n * @template T The type of data returned on success\n */\nexport type Result<T> =\n | {\n data: T;\n success: true;\n }\n | {\n error: AccountError;\n success: false;\n };\n\n/**\n * Standard error type for account-related operations\n */\nexport class AccountError extends Error {\n public details?: any;\n public fields?: Record<string, string>;\n\n constructor(\n message: string,\n public readonly statusCode: number,\n details?: any,\n fields?: Record<string, string>,\n ) {\n super(message);\n this.name = \"AccountError\";\n this.details = details;\n this.fields = fields;\n }\n\n toJSON() {\n return {\n details: this.details,\n fields: this.fields,\n message: this.message,\n statusCode: this.statusCode,\n };\n }\n}\n\n/**\n * Helper function to normalize field values\n */\nfunction normalizeFields(fields: Record<string, any>): Record<string, string> | undefined {\n if (!fields) return undefined;\n \n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(fields)) {\n if (Array.isArray(value)) {\n normalized[key] = value.join(', ');\n } else if (value === null || value === undefined) {\n normalized[key] = '';\n } else if (typeof value === 'object') {\n normalized[key] = JSON.stringify(value);\n } else {\n normalized[key] = String(value);\n }\n }\n return normalized;\n}\n\n/**\n * Extract error details from a response JSON object\n */\nfunction extractErrorDetails(data: any): {\n message: string;\n details?: any;\n fields?: Record<string, string>;\n} {\n let result: {\n message: string;\n details?: any;\n fields?: Record<string, string>;\n } = {\n message: '',\n details: undefined,\n fields: undefined\n };\n\n // Handle standard error format\n if (data?.error) {\n if (typeof data.error === 'string') {\n result.message = data.error;\n } else if (data.error?.message) {\n result.message = data.error.message;\n result.details = data.error.details;\n result.fields = normalizeFields(data.error.fields);\n }\n } \n // Handle alternative error formats\n else if (data?.message) {\n result.message = data.message;\n result.details = data.details;\n result.fields = normalizeFields(data.fields);\n } else {\n result.message = JSON.stringify(data);\n }\n\n // Always include fields if they exist at any level\n if (!result.fields) {\n result.fields = normalizeFields(data?.fields) || normalizeFields(data?.error?.fields);\n }\n\n return result;\n}\n\n/**\n * Convert a failed fetch Response to an AccountError\n * @param response The failed Response object\n * @returns A properly formatted AccountError\n */\nexport async function handleFetchError(\n response: Response,\n): Promise<AccountError> {\n try {\n const contentType = response.headers.get('content-type');\n const isJson = contentType?.toLowerCase()?.includes('json');\n const clone = response.clone();\n let errorData: any;\n\n if (isJson) {\n try {\n errorData = await response.json();\n } catch {\n // Preserve status; fall back to text/statusText\n const txt = await clone.text().catch(() => '');\n errorData = txt || response.statusText;\n }\n } else {\n errorData = await response.text();\n if (!errorData) errorData = response.statusText;\n }\n\n const { message, details, fields } = typeof errorData === 'string' \n ? { message: errorData }\n : extractErrorDetails(errorData);\n\n return new AccountError(\n message || 'Unknown error',\n response.status,\n details,\n fields\n );\n } catch (e) {\n // As a last resort, still preserve the HTTP status when possible\n return new AccountError(\n response.statusText || 'Unknown error',\n response.status,\n { cause: e }\n );\n }\n}\n\n/**\n * Convert an unknown error to an AccountError\n * @param e The unknown error\n * @returns A properly formatted AccountError\n */\nexport function handleUnknownError(e: unknown): AccountError {\n if (e instanceof AccountError) {\n return e;\n }\n\n if (e instanceof Error) {\n return new AccountError(e.message, 500, { cause: e });\n }\n\n if (typeof e === \"object\" && e !== null) {\n let msg: string;\n try {\n msg = JSON.stringify(e);\n } catch {\n msg = String(e);\n }\n return new AccountError(msg, 500, { cause: e });\n }\n\n return new AccountError(String(e), 500);\n}\n\n/**\n * Options for polling/waiting for an operation to complete\n */\nexport interface OperationPollingOptions {\n /** Polling interval in milliseconds (default: 2000) */\n interval?: number;\n /** Maximum time to wait in milliseconds (default: 300000 = 5 minutes) */\n timeout?: number;\n /** Operation statuses that are considered \"settled\" (default: ['completed', 'failed', 'error']) */\n settledStates?: string[];\n}\n\n// Re-export HTTP utilities for convenience\nexport {\n delay,\n isEmptyResponse,\n parseResponse,\n fetchWithHandling,\n poll,\n type PollOptions,\n} from \"@/http-utils\";\n"],"mapp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F,MAAM,SADc,SAAS,QAAQ,IAAI,eAAe,EAC5B,aAAa,EAAE,SAAS,OAAO;EAC3D,MAAM,QAAQ,SAAS,OAAO;EAC9B,IAAI;AAEJ,MAAI,OACF,KAAI;AACF,eAAY,MAAM,SAAS,MAAM;UAC3B;AAGN,eADY,MAAM,MAAM,MAAM,CAAC,YAAY,GAAG,IAC3B,SAAS;;OAEzB;AACL,eAAY,MAAM,SAAS,MAAM;AACjC,OAAI,CAAC,UAAW,aAAY,SAAS;;EAGvC,MAAM,EAAE,SAAS,SAAS,WAAW,OAAO,cAAc,WACtD,EAAE,SAAS,WAAW,GACtB,oBAAoB,UAAU;AAElC,SAAO,IAAI,aACT,WAAW,iBACX,SAAS,QACT,SACA,OACD;UACM,GAAG;AAEV,SAAO,IAAI,aACT,SAAS,cAAc,iBACvB,SAAS,QACT,EAAE,OAAO,GAAG,CACb;;;;;;;;AASL,SAAgB,mBAAmB,GAA0B;AAC3D,KAAI,aAAa,aACf,QAAO;AAGT,KAAI,aAAa,MACf,QAAO,IAAI,aAAa,EAAE,SAAS,KAAK,EAAE,OAAO,GAAG,CAAC;AAGvD,KAAI,OAAO,MAAM,YAAY,MAAM,MAAM;EACvC,IAAI;AACJ,MAAI;AACF,SAAM,KAAK,UAAU,EAAE;UACjB;AACN,SAAM,OAAO,EAAE;;AAEjB,SAAO,IAAI,aAAa,KAAK,KAAK,EAAE,OAAO,GAAG,CAAC;;AAGjD,QAAO,IAAI,aAAa,OAAO,EAAE,EAAE,IAAI"}
@@ -1,58 +0,0 @@
1
- import { PollOptions, delay, fetchWithHandling, isEmptyResponse, parseResponse, poll } from "./http-utils.cjs";
2
-
3
- //#region src/types.d.ts
4
- interface RequestInit extends Omit<globalThis.RequestInit, "headers"> {
5
- headers?: Record<string, string>;
6
- }
7
- /**
8
- * Generic Result type for consistent error handling
9
- * @template T The type of data returned on success
10
- */
11
- type Result<T> = {
12
- data: T;
13
- success: true;
14
- } | {
15
- error: AccountError;
16
- success: false;
17
- };
18
- /**
19
- * Standard error type for account-related operations
20
- */
21
- declare class AccountError extends Error {
22
- readonly statusCode: number;
23
- details?: any;
24
- fields?: Record<string, string>;
25
- constructor(message: string, statusCode: number, details?: any, fields?: Record<string, string>);
26
- toJSON(): {
27
- details: any;
28
- fields: Record<string, string> | undefined;
29
- message: string;
30
- statusCode: number;
31
- };
32
- }
33
- /**
34
- * Convert a failed fetch Response to an AccountError
35
- * @param response The failed Response object
36
- * @returns A properly formatted AccountError
37
- */
38
- declare function handleFetchError(response: Response): Promise<AccountError>;
39
- /**
40
- * Convert an unknown error to an AccountError
41
- * @param e The unknown error
42
- * @returns A properly formatted AccountError
43
- */
44
- declare function handleUnknownError(e: unknown): AccountError;
45
- /**
46
- * Options for polling/waiting for an operation to complete
47
- */
48
- interface OperationPollingOptions {
49
- /** Polling interval in milliseconds (default: 2000) */
50
- interval?: number;
51
- /** Maximum time to wait in milliseconds (default: 300000 = 5 minutes) */
52
- timeout?: number;
53
- /** Operation statuses that are considered "settled" (default: ['completed', 'failed', 'error']) */
54
- settledStates?: string[];
55
- }
56
- //#endregion
57
- export { AccountError, OperationPollingOptions, type PollOptions, RequestInit, Result, delay, fetchWithHandling, handleFetchError, handleUnknownError, isEmptyResponse, parseResponse, poll };
58
- //# sourceMappingURL=types.d.cts.map