vintasend-medplum 0.4.11 → 0.4.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"medplum-attachment-manager.d.ts","sourceRoot":"","sources":["../src/medplum-attachment-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oEAAoE,CAAC;AAC3G,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,cAAc,EACf,MAAM,iCAAiC,CAAC;AAEzC;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,qBAAqB;IACrD,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAI1C;;;;;;;OAOG;IACG,UAAU,CACd,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAkEhC;;;;;OAKG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA0BnE;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB/C;;;;;OAKG;IACH,yBAAyB,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;CAgBpF;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,cAAc;IAIxD,OAAO,CAAC,OAAO;IAHjB,OAAO,CAAC,QAAQ,CAAS;gBAGf,OAAO,EAAE,aAAa,EAC9B,SAAS,EAAE,MAAM;IAwBnB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ7B;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAUvC;;;;;;;;OAQG;IACG,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,CAAC,SAAS,SAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAO5C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
@@ -168,21 +168,24 @@ export class MedplumAttachmentManager extends BaseAttachmentManager {
168
168
  */
169
169
  export class MedplumAttachmentFile {
170
170
  constructor(medplum, binaryUrl) {
171
+ this.medplum = medplum;
171
172
  // Extract Binary ID from URL
172
173
  // Supports two formats:
173
174
  // 1. Simple reference: "Binary/{id}"
174
175
  // 2. Full Medplum storage URL: "https://storage.medplum.com/binary/{projectId}/{binaryId}?..."
175
- this.medplum = medplum;
176
+ console.log(`[MedplumAttachmentFile] Constructing with binaryUrl: ${binaryUrl}`);
176
177
  // Try to extract from full URL first
177
178
  const fullUrlMatch = binaryUrl.match(/\/binary\/[^/]+\/([^/?]+)/);
178
179
  if (fullUrlMatch) {
179
180
  this.binaryId = fullUrlMatch[1];
181
+ console.log(`[MedplumAttachmentFile] Extracted binaryId from full URL: ${this.binaryId}`);
180
182
  return;
181
183
  }
182
184
  // Fall back to simple Binary reference
183
185
  const simpleMatch = binaryUrl.match(/Binary\/([^/]+)/);
184
186
  if (simpleMatch) {
185
187
  this.binaryId = simpleMatch[1];
188
+ console.log(`[MedplumAttachmentFile] Extracted binaryId from simple reference: ${this.binaryId}`);
186
189
  return;
187
190
  }
188
191
  throw new Error(`Invalid Binary URL format: ${binaryUrl}`);
@@ -191,11 +194,22 @@ export class MedplumAttachmentFile {
191
194
  * Read the entire file into memory as a Buffer.
192
195
  */
193
196
  async read() {
194
- const binary = await this.medplum.readResource('Binary', this.binaryId);
195
- if (!binary.data) {
196
- throw new Error('Binary resource has no data');
197
+ try {
198
+ console.log(`[MedplumAttachmentFile.read] Reading Binary resource with ID: ${this.binaryId}`);
199
+ const binary = await this.medplum.readResource('Binary', this.binaryId);
200
+ console.log(`[MedplumAttachmentFile.read] Successfully fetched Binary resource: ${this.binaryId}`);
201
+ if (!binary.data) {
202
+ throw new Error('Binary resource has no data');
203
+ }
204
+ const buffer = Buffer.from(binary.data, 'base64');
205
+ console.log(`[MedplumAttachmentFile.read] Successfully converted to buffer, size: ${buffer.length} bytes`);
206
+ return buffer;
207
+ }
208
+ catch (error) {
209
+ console.error(`[MedplumAttachmentFile.read] Error reading Binary ${this.binaryId}:`, error);
210
+ console.error(`[MedplumAttachmentFile.read] Error details:`, JSON.stringify(error, null, 2));
211
+ throw error;
197
212
  }
198
- return Buffer.from(binary.data, 'base64');
199
213
  }
200
214
  /**
201
215
  * Get a readable stream for the file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vintasend-medplum",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {