@financeable/lenders 0.5.4 → 0.5.5

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 (82) hide show
  1. package/README.md +11 -7
  2. package/bin/mcp-server.js +19 -14
  3. package/bin/mcp-server.js.map +11 -11
  4. package/dist/commonjs/lib/config.d.ts +3 -3
  5. package/dist/commonjs/lib/config.js +3 -3
  6. package/dist/commonjs/lib/config.js.map +1 -1
  7. package/dist/commonjs/lib/encodings.d.ts +1 -0
  8. package/dist/commonjs/lib/encodings.d.ts.map +1 -1
  9. package/dist/commonjs/lib/encodings.js +27 -5
  10. package/dist/commonjs/lib/encodings.js.map +1 -1
  11. package/dist/commonjs/lib/files.d.ts +13 -0
  12. package/dist/commonjs/lib/files.d.ts.map +1 -1
  13. package/dist/commonjs/lib/files.js +19 -0
  14. package/dist/commonjs/lib/files.js.map +1 -1
  15. package/dist/commonjs/lib/matchers.d.ts.map +1 -1
  16. package/dist/commonjs/lib/matchers.js +0 -1
  17. package/dist/commonjs/lib/matchers.js.map +1 -1
  18. package/dist/commonjs/lib/sdks.d.ts.map +1 -1
  19. package/dist/commonjs/lib/sdks.js +8 -4
  20. package/dist/commonjs/lib/sdks.js.map +1 -1
  21. package/dist/commonjs/lib/security.d.ts.map +1 -1
  22. package/dist/commonjs/lib/security.js +1 -2
  23. package/dist/commonjs/lib/security.js.map +1 -1
  24. package/dist/commonjs/lib/url.d.ts.map +1 -1
  25. package/dist/commonjs/lib/url.js +4 -2
  26. package/dist/commonjs/lib/url.js.map +1 -1
  27. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  28. package/dist/commonjs/mcp-server/server.js +1 -1
  29. package/dist/commonjs/mcp-server/shared.js +1 -1
  30. package/dist/commonjs/mcp-server/shared.js.map +1 -1
  31. package/dist/commonjs/models/components/customerprofile.d.ts +2 -0
  32. package/dist/commonjs/models/components/customerprofile.d.ts.map +1 -1
  33. package/dist/commonjs/models/components/customerprofile.js +2 -0
  34. package/dist/commonjs/models/components/customerprofile.js.map +1 -1
  35. package/dist/esm/lib/config.d.ts +3 -3
  36. package/dist/esm/lib/config.js +3 -3
  37. package/dist/esm/lib/config.js.map +1 -1
  38. package/dist/esm/lib/encodings.d.ts +1 -0
  39. package/dist/esm/lib/encodings.d.ts.map +1 -1
  40. package/dist/esm/lib/encodings.js +26 -5
  41. package/dist/esm/lib/encodings.js.map +1 -1
  42. package/dist/esm/lib/files.d.ts +13 -0
  43. package/dist/esm/lib/files.d.ts.map +1 -1
  44. package/dist/esm/lib/files.js +18 -0
  45. package/dist/esm/lib/files.js.map +1 -1
  46. package/dist/esm/lib/matchers.d.ts.map +1 -1
  47. package/dist/esm/lib/matchers.js +0 -1
  48. package/dist/esm/lib/matchers.js.map +1 -1
  49. package/dist/esm/lib/sdks.d.ts.map +1 -1
  50. package/dist/esm/lib/sdks.js +8 -4
  51. package/dist/esm/lib/sdks.js.map +1 -1
  52. package/dist/esm/lib/security.d.ts.map +1 -1
  53. package/dist/esm/lib/security.js +1 -2
  54. package/dist/esm/lib/security.js.map +1 -1
  55. package/dist/esm/lib/url.d.ts.map +1 -1
  56. package/dist/esm/lib/url.js +4 -2
  57. package/dist/esm/lib/url.js.map +1 -1
  58. package/dist/esm/mcp-server/mcp-server.js +1 -1
  59. package/dist/esm/mcp-server/server.js +1 -1
  60. package/dist/esm/mcp-server/shared.js +1 -1
  61. package/dist/esm/mcp-server/shared.js.map +1 -1
  62. package/dist/esm/models/components/customerprofile.d.ts +2 -0
  63. package/dist/esm/models/components/customerprofile.d.ts.map +1 -1
  64. package/dist/esm/models/components/customerprofile.js +2 -0
  65. package/dist/esm/models/components/customerprofile.js.map +1 -1
  66. package/jsr.json +1 -1
  67. package/package.json +2 -2
  68. package/src/lib/config.ts +3 -3
  69. package/src/lib/encodings.ts +32 -4
  70. package/src/lib/files.ts +22 -0
  71. package/src/lib/matchers.ts +3 -2
  72. package/src/lib/sdks.ts +7 -5
  73. package/src/lib/security.ts +1 -2
  74. package/src/lib/url.ts +16 -14
  75. package/src/mcp-server/mcp-server.ts +1 -1
  76. package/src/mcp-server/server.ts +1 -1
  77. package/src/mcp-server/shared.ts +2 -2
  78. package/src/models/components/customerprofile.ts +4 -0
  79. package/.devcontainer/devcontainer.json +0 -45
  80. package/examples/package-lock.json +0 -620
  81. package/examples/package.json +0 -18
  82. package/tsconfig.json +0 -40
@@ -479,6 +479,23 @@ export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited);
479
479
  export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited);
480
480
  export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject);
481
481
 
482
+ function isBlobLike(val: unknown): val is Blob {
483
+ if (val instanceof Blob) {
484
+ return true;
485
+ }
486
+
487
+ if (typeof val !== "object" || val == null || !(Symbol.toStringTag in val)) {
488
+ return false;
489
+ }
490
+
491
+ const tag = val[Symbol.toStringTag];
492
+ if (tag !== "Blob" && tag !== "File") {
493
+ return false;
494
+ }
495
+
496
+ return "stream" in val && typeof val.stream === "function";
497
+ }
498
+
482
499
  export function appendForm(
483
500
  fd: FormData,
484
501
  key: string,
@@ -487,11 +504,22 @@ export function appendForm(
487
504
  ): void {
488
505
  if (value == null) {
489
506
  return;
490
- } else if (value instanceof Blob && fileName) {
491
- fd.append(key, value, fileName);
492
- } else if (value instanceof Blob) {
493
- fd.append(key, value);
507
+ } else if (isBlobLike(value)) {
508
+ if (fileName) {
509
+ fd.append(key, value as Blob, fileName);
510
+ } else {
511
+ fd.append(key, value as Blob);
512
+ }
494
513
  } else {
495
514
  fd.append(key, String(value));
496
515
  }
497
516
  }
517
+
518
+ export async function normalizeBlob(
519
+ value: Pick<Blob, "arrayBuffer" | "type">,
520
+ ): Promise<Blob> {
521
+ if (value instanceof Blob) {
522
+ return value;
523
+ }
524
+ return new Blob([await value.arrayBuffer()], { type: value.type });
525
+ }
package/src/lib/files.ts CHANGED
@@ -80,3 +80,25 @@ export function getContentTypeFromFileName(fileName: string): string | null {
80
80
 
81
81
  return mimeTypes[ext] || null;
82
82
  }
83
+
84
+ /**
85
+ * Creates a Blob from file content with the given MIME type.
86
+ *
87
+ * Node.js Buffers are Uint8Array subclasses that may share a pooled
88
+ * ArrayBuffer (byteOffset > 0, byteLength < buffer.byteLength). Passing
89
+ * such a Buffer directly to `new Blob([buf])` can include the entire
90
+ * underlying pool on some runtimes, producing a Blob with extra bytes
91
+ * that corrupts multipart uploads.
92
+ *
93
+ * Copying into a standalone Uint8Array ensures the Blob receives only the
94
+ * intended bytes regardless of runtime behaviour.
95
+ */
96
+ export function bytesToBlob(
97
+ content: Uint8Array<ArrayBufferLike> | ArrayBuffer | Blob | string,
98
+ contentType: string,
99
+ ): Blob {
100
+ if (content instanceof Uint8Array) {
101
+ return new Blob([new Uint8Array(content)], { type: contentType });
102
+ }
103
+ return new Blob([content as BlobPart], { type: contentType });
104
+ }
@@ -248,8 +248,9 @@ export function match<T, E>(
248
248
  raw = body;
249
249
  break;
250
250
  default:
251
- encoding satisfies never;
252
- throw new Error(`Unsupported response type: ${encoding}`);
251
+ throw new Error(
252
+ `Unsupported response type: ${encoding satisfies never}`,
253
+ );
253
254
  }
254
255
 
255
256
  if (matcher.enc === "fail") {
package/src/lib/sdks.ts CHANGED
@@ -127,13 +127,15 @@ export class ClientSDK {
127
127
  if (!base) {
128
128
  return ERR(new InvalidRequestError("No base URL provided for operation"));
129
129
  }
130
- const reqURL = new URL(base);
131
- const inputURL = new URL(path, reqURL);
132
-
130
+ const baseURL = new URL(base);
131
+ let reqURL: URL;
133
132
  if (path) {
134
- reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/";
135
- reqURL.pathname += inputURL.pathname.replace(/^\/+/, "");
133
+ baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
134
+ reqURL = new URL(path, baseURL);
135
+ } else {
136
+ reqURL = baseURL;
136
137
  }
138
+ reqURL.hash = "";
137
139
 
138
140
  let finalQuery = query || "";
139
141
 
@@ -195,8 +195,7 @@ export function resolveSecurity(
195
195
  applyBearer(state, spec);
196
196
  break;
197
197
  default:
198
- spec satisfies never;
199
- throw SecurityError.unrecognizedType(type);
198
+ throw SecurityError.unrecognizedType((spec satisfies never, type));
200
199
  }
201
200
  });
202
201
 
package/src/lib/url.ts CHANGED
@@ -13,21 +13,23 @@ export function pathToFunc(
13
13
  const paramRE = /\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;
14
14
 
15
15
  return function buildURLPath(params: Record<string, unknown> = {}): string {
16
- return pathPattern.replace(paramRE, function (_, placeholder) {
17
- if (!hasOwn.call(params, placeholder)) {
18
- throw new Error(`Parameter '${placeholder}' is required`);
19
- }
16
+ return pathPattern
17
+ .replace(paramRE, function (_, placeholder) {
18
+ if (!hasOwn.call(params, placeholder)) {
19
+ throw new Error(`Parameter '${placeholder}' is required`);
20
+ }
20
21
 
21
- const value = params[placeholder];
22
- if (typeof value !== "string" && typeof value !== "number") {
23
- throw new Error(
24
- `Parameter '${placeholder}' must be a string or number`,
25
- );
26
- }
22
+ const value = params[placeholder];
23
+ if (typeof value !== "string" && typeof value !== "number") {
24
+ throw new Error(
25
+ `Parameter '${placeholder}' must be a string or number`,
26
+ );
27
+ }
27
28
 
28
- return options?.charEncoding === "percent"
29
- ? encodeURIComponent(`${value}`)
30
- : `${value}`;
31
- });
29
+ return options?.charEncoding === "percent"
30
+ ? encodeURIComponent(`${value}`)
31
+ : `${value}`;
32
+ })
33
+ .replace(/^\/+/, "");
32
34
  };
33
35
  }
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.5.4",
22
+ currentVersion: "0.5.5",
23
23
  },
24
24
  });
25
25
 
@@ -27,7 +27,7 @@ export function createMCPServer(deps: {
27
27
  }) {
28
28
  const server = new McpServer({
29
29
  name: "FinanceableLenders",
30
- version: "0.5.4",
30
+ version: "0.5.5",
31
31
  });
32
32
 
33
33
  const client = new FinanceableLendersCore({
@@ -16,12 +16,12 @@ export async function consumeStream(
16
16
  stream: ReadableStream<Uint8Array>,
17
17
  ): Promise<Uint8Array> {
18
18
  const reader = stream.getReader();
19
- const chunks: Uint8Array[] = [];
19
+ const chunks: ArrayBuffer[] = [];
20
20
 
21
21
  try {
22
22
  while (true) {
23
23
  const { done, value } = await reader.read();
24
- if (value != null) chunks.push(value);
24
+ if (value != null) chunks.push(new Uint8Array(value).buffer);
25
25
  if (done) break;
26
26
  }
27
27
  } finally {
@@ -45,6 +45,7 @@ export type CustomerProfile = {
45
45
  shareOfExpenses?: number | undefined;
46
46
  rentAmount?: string | undefined;
47
47
  landlordName?: string | undefined;
48
+ serviceabilitySurplus?: number | undefined;
48
49
  };
49
50
 
50
51
  /** @internal */
@@ -62,6 +63,7 @@ export const CustomerProfile$inboundSchema: z.ZodType<
62
63
  shareOfExpenses: z.number().optional(),
63
64
  rentAmount: z.string().optional(),
64
65
  landlordName: z.string().optional(),
66
+ serviceabilitySurplus: z.number().optional(),
65
67
  }).transform((v) => {
66
68
  return remap$(v, {
67
69
  "_id": "id",
@@ -78,6 +80,7 @@ export type CustomerProfile$Outbound = {
78
80
  shareOfExpenses?: number | undefined;
79
81
  rentAmount?: string | undefined;
80
82
  landlordName?: string | undefined;
83
+ serviceabilitySurplus?: number | undefined;
81
84
  };
82
85
 
83
86
  /** @internal */
@@ -95,6 +98,7 @@ export const CustomerProfile$outboundSchema: z.ZodType<
95
98
  shareOfExpenses: z.number().optional(),
96
99
  rentAmount: z.string().optional(),
97
100
  landlordName: z.string().optional(),
101
+ serviceabilitySurplus: z.number().optional(),
98
102
  }).transform((v) => {
99
103
  return remap$(v, {
100
104
  id: "_id",
@@ -1,45 +0,0 @@
1
- // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
- // README at: https://github.com/devcontainers/images/tree/main/src/typescript-node
3
- {
4
- "name": "TypeScript",
5
- "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
6
- // Features to add to the dev container. More info: https://containers.dev/features.
7
- // "features": {},
8
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
9
- // "forwardPorts": [],
10
- // Use 'postCreateCommand' to run commands after the container is created.
11
- "postCreateCommand": "sudo chmod +x ./.devcontainer/setup.sh && ./.devcontainer/setup.sh",
12
- "customizations": {
13
- "vscode": {
14
- "extensions": [
15
- "ms-vscode.vscode-typescript-tslint-plugin",
16
- "esbenp.prettier-vscode",
17
- "github.vscode-pull-request-github"
18
- ],
19
- "settings": {
20
- "files.eol": "\n",
21
- "editor.formatOnSave": true,
22
- "typescript.tsc.autoDetect": "on",
23
- "typescript.updateImportsOnFileMove.enabled": "always",
24
- "typescript.preferences.importModuleSpecifier": "relative",
25
- "[typescript]": {
26
- "editor.codeActionsOnSave": {
27
- "source.organizeImports": true
28
- }
29
- },
30
- "[typescriptreact]": {
31
- "editor.codeActionsOnSave": {
32
- "source.organizeImports": true
33
- }
34
- }
35
- }
36
- },
37
- "codespaces": {
38
- "openFiles": [
39
- ".devcontainer/README.md"
40
- ]
41
- }
42
- }
43
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
44
- // "remoteUser": "root"
45
- }