@oystehr/sdk 3.0.1 → 3.0.3
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/dist/cjs/client/client.d.ts +2 -1
- package/dist/cjs/index.cjs +106 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.d.ts +13 -0
- package/dist/cjs/resources/classes/fhir.d.ts +2 -0
- package/dist/cjs/resources/classes/z3-ext.d.ts +22 -0
- package/dist/cjs/resources/classes/z3.d.ts +15 -0
- package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +1 -1
- package/dist/cjs/resources/types/fhir.d.ts +6 -3
- package/dist/esm/client/client.d.ts +2 -1
- package/dist/esm/client/client.js +1 -1
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.d.ts +13 -0
- package/dist/esm/resources/classes/fhir-ext.js +44 -2
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/fhir.d.ts +2 -0
- package/dist/esm/resources/classes/fhir.js +3 -1
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/classes/z3-ext.d.ts +22 -0
- package/dist/esm/resources/classes/z3-ext.js +49 -1
- package/dist/esm/resources/classes/z3-ext.js.map +1 -1
- package/dist/esm/resources/classes/z3.d.ts +15 -0
- package/dist/esm/resources/classes/z3.js +16 -1
- package/dist/esm/resources/classes/z3.js.map +1 -1
- package/dist/esm/resources/types/ZambdaCreateParams.d.ts +1 -1
- package/dist/esm/resources/types/fhir.d.ts +6 -3
- package/package.json +1 -1
- package/src/client/client.ts +2 -2
- package/src/resources/classes/fhir-ext.ts +69 -1
- package/src/resources/classes/fhir.ts +2 -0
- package/src/resources/classes/z3-ext.ts +48 -1
- package/src/resources/classes/z3.ts +15 -0
- package/src/resources/types/ZambdaCreateParams.ts +1 -1
- package/src/resources/types/fhir.ts +4 -3
- package/dist/cjs/fhir/fhir-types.d.ts +0 -9
- package/dist/cjs/fhir/index.d.ts +0 -2
- package/dist/cjs/fhir/utils.d.ts +0 -14
- package/dist/esm/fhir/fhir-types.d.ts +0 -9
- package/dist/esm/fhir/index.d.ts +0 -2
- package/dist/esm/fhir/utils.d.ts +0 -14
- package/src/fhir/fhir-types.ts +0 -15
- package/src/fhir/index.ts +0 -2
- package/src/fhir/utils.ts +0 -68
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';
|
|
2
|
+
import { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';
|
|
1
3
|
import { BatchInput, Bundle, FhirCreateParams, FhirDeleteParams, FhirGetParams, FhirHistoryGetParams, FhirHistorySearchParams, FhirPatchParams, FhirResource, FhirSearchParams, FhirUpdateParams } from '../..';
|
|
2
4
|
import { FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
|
|
3
5
|
/**
|
|
@@ -32,3 +34,14 @@ export declare function history<T extends FhirResource>(this: SDKResource, { res
|
|
|
32
34
|
export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: FhirHistoryGetParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
|
|
33
35
|
export declare const batch: <BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest) => Promise<Bundle<BundleContentType>>;
|
|
34
36
|
export declare const transaction: <BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest) => Promise<Bundle<BundleContentType>>;
|
|
37
|
+
export declare function formatAddress(address: AddressR4B | AddressR5, options?: {
|
|
38
|
+
all?: boolean;
|
|
39
|
+
use?: boolean;
|
|
40
|
+
lineSeparator?: string;
|
|
41
|
+
}): string;
|
|
42
|
+
export declare function formatHumanName(name: HumanNameR4B | HumanNameR5, options?: {
|
|
43
|
+
all?: boolean;
|
|
44
|
+
prefix?: boolean;
|
|
45
|
+
suffix?: boolean;
|
|
46
|
+
use?: boolean;
|
|
47
|
+
}): string;
|
|
@@ -22,7 +22,7 @@ function search(params, request) {
|
|
|
22
22
|
}, {});
|
|
23
23
|
}
|
|
24
24
|
const requestBundle = yield this.fhirRequest(`/${resourceType}/_search`, 'POST')(paramMap, Object.assign(Object.assign({}, request), { contentType: 'application/x-www-form-urlencoded' }));
|
|
25
|
-
const bundle = Object.assign(Object.assign({}, requestBundle), { unbundle: function () {
|
|
25
|
+
const bundle = Object.assign(Object.assign({}, requestBundle), { entry: requestBundle.entry, unbundle: function () {
|
|
26
26
|
var _a, _b;
|
|
27
27
|
return (_b = (_a = this.entry) === null || _a === void 0 ? void 0 : _a.map((entry) => entry.resource).filter((entry) => entry !== undefined)) !== null && _b !== void 0 ? _b : [];
|
|
28
28
|
} });
|
|
@@ -126,6 +126,48 @@ function bundleRequest(type) {
|
|
|
126
126
|
}
|
|
127
127
|
const batch = bundleRequest('batch');
|
|
128
128
|
const transaction = bundleRequest('transaction');
|
|
129
|
+
function formatAddress(address, options) {
|
|
130
|
+
const builder = [];
|
|
131
|
+
if (address.line) {
|
|
132
|
+
builder.push(...address.line);
|
|
133
|
+
}
|
|
134
|
+
if (address.city || address.state || address.postalCode) {
|
|
135
|
+
const cityStateZip = [];
|
|
136
|
+
if (address.city) {
|
|
137
|
+
cityStateZip.push(address.city);
|
|
138
|
+
}
|
|
139
|
+
if (address.state) {
|
|
140
|
+
cityStateZip.push(address.state);
|
|
141
|
+
}
|
|
142
|
+
if (address.postalCode) {
|
|
143
|
+
cityStateZip.push(address.postalCode);
|
|
144
|
+
}
|
|
145
|
+
builder.push(cityStateZip.join(', '));
|
|
146
|
+
}
|
|
147
|
+
if (address.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
|
|
148
|
+
builder.push('[' + address.use + ']');
|
|
149
|
+
}
|
|
150
|
+
return builder.join((options === null || options === void 0 ? void 0 : options.lineSeparator) || ', ').trim();
|
|
151
|
+
}
|
|
152
|
+
function formatHumanName(name, options) {
|
|
153
|
+
const builder = [];
|
|
154
|
+
if (name.prefix && (options === null || options === void 0 ? void 0 : options.prefix) !== false) {
|
|
155
|
+
builder.push(...name.prefix);
|
|
156
|
+
}
|
|
157
|
+
if (name.given) {
|
|
158
|
+
builder.push(...name.given);
|
|
159
|
+
}
|
|
160
|
+
if (name.family) {
|
|
161
|
+
builder.push(name.family);
|
|
162
|
+
}
|
|
163
|
+
if (name.suffix && (options === null || options === void 0 ? void 0 : options.suffix) !== false) {
|
|
164
|
+
builder.push(...name.suffix);
|
|
165
|
+
}
|
|
166
|
+
if (name.use && ((options === null || options === void 0 ? void 0 : options.all) || (options === null || options === void 0 ? void 0 : options.use))) {
|
|
167
|
+
builder.push('[' + name.use + ']');
|
|
168
|
+
}
|
|
169
|
+
return builder.join(' ').trim();
|
|
170
|
+
}
|
|
129
171
|
|
|
130
|
-
export { batch, create, del as delete, get, history, patch, search, transaction, update };
|
|
172
|
+
export { batch, create, del as delete, formatAddress, formatHumanName, get, history, patch, search, transaction, update };
|
|
131
173
|
//# sourceMappingURL=fhir-ext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import {\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirSearchParams,\n FhirUpdateParams,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType, params: searchParams } = params;\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (searchParams) {\n paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n unbundle: function (this: Bundle<T>) {\n return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { resourceType } = params;\n return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { id, resourceType } = params;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: { resourceType: string; id: string; versionId?: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}/_history${versionId ? `/${versionId}` : ''}`, 'GET')({}, request);\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>\n): BundleEntry<T | Binary<T>> {\n const { method, url } = request;\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n acc[name] = value;\n return acc;\n }, {} as Record<string, string>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const { resource } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n return {\n ...baseRequest,\n resource: request.resource,\n } as BundleEntry<Binary<T>>;\n }\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data: Buffer.from(JSON.stringify(request.operations), 'utf8').toString('base64'),\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST creates require a full resource\n if (method === 'POST') {\n const { resource, fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n throw new Error('Unrecognized method');\n}\n\nfunction bundleRequest(type: 'batch' | 'transaction') {\n return async function <BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n ): Promise<FhirFetcherResponse<Bundle<BundleContentType>>> {\n return this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type,\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n };\n}\n\nexport const batch = bundleRequest('batch');\nexport const transaction = bundleRequest('transaction');\n"],"names":[],"mappings":";;;AAkCA;;;;;;AAMG;AACmB,SAAA,MAAM,CAE1B,MAAwB,EACxB,OAA8B,EAAA;;QAE9B,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EA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AACJ,CAAC;MAEY,KAAK,GAAG,aAAa,CAAC,OAAO,EAAE;MAC/B,WAAW,GAAG,aAAa,CAAC,aAAa;;;;"}
|
|
1
|
+
{"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';\nimport { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';\nimport {\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirSearchParams,\n FhirUpdateParams,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType, params: searchParams } = params;\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (searchParams) {\n paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {\n return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { resourceType } = params;\n return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { id, resourceType } = params;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: { resourceType: string; id: string; versionId?: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}/_history${versionId ? `/${versionId}` : ''}`, 'GET')({}, request);\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>\n): BundleEntry<T | Binary<T>> {\n const { method, url } = request;\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n acc[name] = value;\n return acc;\n }, {} as Record<string, string>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const { resource } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n return {\n ...baseRequest,\n resource: request.resource,\n } as BundleEntry<Binary<T>>;\n }\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data: Buffer.from(JSON.stringify(request.operations), 'utf8').toString('base64'),\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST creates require a full resource\n if (method === 'POST') {\n const { resource, fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n throw new Error('Unrecognized method');\n}\n\nfunction bundleRequest(type: 'batch' | 'transaction') {\n return async function <BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n ): Promise<FhirFetcherResponse<Bundle<BundleContentType>>> {\n return this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type,\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n };\n}\n\nexport const batch = bundleRequest('batch');\nexport const transaction = bundleRequest('transaction');\n\nexport function formatAddress(\n address: AddressR4B | AddressR5,\n options?: { all?: boolean; use?: boolean; lineSeparator?: string }\n): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\nexport function formatHumanName(\n name: HumanNameR4B | HumanNameR5,\n options?: {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n }\n): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join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AO,CAAE,GAAG,MAAI,OAAO,KAAA,IAAA,IAAP,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAP,OAAO,CAAE,GAAG,CAAA,CAAC,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AACpC,KAAA;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAClC;;;;"}
|
|
@@ -18,4 +18,6 @@ export declare class Fhir extends SDKResource {
|
|
|
18
18
|
history: typeof ext.history;
|
|
19
19
|
batch: <BundleContentType extends import("..").FhirResource>(this: SDKResource, input: import("..").BatchInput<BundleContentType>, request?: import("../../client/client").OystehrClientRequest | undefined) => Promise<import("..").Bundle<BundleContentType>>;
|
|
20
20
|
transaction: <BundleContentType extends import("..").FhirResource>(this: SDKResource, input: import("..").BatchInput<BundleContentType>, request?: import("../../client/client").OystehrClientRequest | undefined) => Promise<import("..").Bundle<BundleContentType>>;
|
|
21
|
+
formatAddress: typeof ext.formatAddress;
|
|
22
|
+
formatHumanName: typeof ext.formatHumanName;
|
|
21
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client.js';
|
|
2
|
-
import { search, create, get, update, patch, delete as del, history, batch, transaction } from './fhir-ext.js';
|
|
2
|
+
import { search, create, get, update, patch, delete as del, history, batch, transaction, formatAddress, formatHumanName } from './fhir-ext.js';
|
|
3
3
|
|
|
4
4
|
// AUTOGENERATED -- DO NOT EDIT
|
|
5
5
|
class Fhir extends SDKResource {
|
|
@@ -20,6 +20,8 @@ class Fhir extends SDKResource {
|
|
|
20
20
|
this.history = history;
|
|
21
21
|
this.batch = batch;
|
|
22
22
|
this.transaction = transaction;
|
|
23
|
+
this.formatAddress = formatAddress;
|
|
24
|
+
this.formatHumanName = formatHumanName;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhir.js","sources":["../../../../src/resources/classes/fhir.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './fhir-ext';\n\nexport class Fhir extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n /**\n * Performs a FHIR search and returns the results as a Bundle resource\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\n search = ext.search;\n create = ext.create;\n get = ext.get;\n update = ext.update;\n patch = ext.patch;\n delete = ext.delete;\n history = ext.history;\n batch = ext.batch;\n transaction = ext.transaction;\n}\n"],"names":["ext.search","ext.create","ext.get","ext.update","ext.patch","ext.delete","ext.history","ext.batch","ext.transaction"],"mappings":";;;AAAA;AAMM,MAAO,IAAK,SAAQ,WAAW,CAAA;AACnC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;AAKG;AACH,QAAA,IAAA,CAAA,MAAM,GAAGA,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,MAAM,GAAGC,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,GAAG,GAAGC,GAAO,CAAC;AACd,QAAA,IAAA,CAAA,MAAM,GAAGC,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,KAAK,GAAGC,KAAS,CAAC;AAClB,QAAA,IAAA,CAAA,MAAM,GAAGC,GAAU,CAAC;AACpB,QAAA,IAAA,CAAA,OAAO,GAAGC,OAAW,CAAC;AACtB,QAAA,IAAA,CAAA,KAAK,GAAGC,KAAS,CAAC;AAClB,QAAA,IAAA,CAAA,WAAW,GAAGC,WAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"fhir.js","sources":["../../../../src/resources/classes/fhir.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './fhir-ext';\n\nexport class Fhir extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n /**\n * Performs a FHIR search and returns the results as a Bundle resource\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\n search = ext.search;\n create = ext.create;\n get = ext.get;\n update = ext.update;\n patch = ext.patch;\n delete = ext.delete;\n history = ext.history;\n batch = ext.batch;\n transaction = ext.transaction;\n formatAddress = ext.formatAddress;\n formatHumanName = ext.formatHumanName;\n}\n"],"names":["ext.search","ext.create","ext.get","ext.update","ext.patch","ext.delete","ext.history","ext.batch","ext.transaction","ext.formatAddress","ext.formatHumanName"],"mappings":";;;AAAA;AAMM,MAAO,IAAK,SAAQ,WAAW,CAAA;AACnC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;AAKG;AACH,QAAA,IAAA,CAAA,MAAM,GAAGA,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,MAAM,GAAGC,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,GAAG,GAAGC,GAAO,CAAC;AACd,QAAA,IAAA,CAAA,MAAM,GAAGC,MAAU,CAAC;AACpB,QAAA,IAAA,CAAA,KAAK,GAAGC,KAAS,CAAC;AAClB,QAAA,IAAA,CAAA,MAAM,GAAGC,GAAU,CAAC;AACpB,QAAA,IAAA,CAAA,OAAO,GAAGC,OAAW,CAAC;AACtB,QAAA,IAAA,CAAA,KAAK,GAAGC,KAAS,CAAC;AAClB,QAAA,IAAA,CAAA,WAAW,GAAGC,WAAe,CAAC;AAC9B,QAAA,IAAA,CAAA,aAAa,GAAGC,aAAiB,CAAC;AAClC,QAAA,IAAA,CAAA,eAAe,GAAGC,eAAmB,CAAC;KAjBrC;AAkBF;;;;"}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client';
|
|
2
|
+
import { Z3GetPresignedUrlParams, Z3GetPresignedUrlResponse } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
5
|
+
*
|
|
6
|
+
* @param params upload file params
|
|
7
|
+
*/
|
|
2
8
|
export declare function uploadFile(this: SDKResource, { bucketName, 'objectPath+': key, file, }: {
|
|
3
9
|
bucketName: string;
|
|
4
10
|
'objectPath+': string;
|
|
5
11
|
file: Blob;
|
|
6
12
|
}): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
15
|
+
*
|
|
16
|
+
* @param params download file params
|
|
17
|
+
*/
|
|
7
18
|
export declare function downloadFile(this: SDKResource, { bucketName, 'objectPath+': key, }: {
|
|
8
19
|
bucketName: string;
|
|
9
20
|
'objectPath+': string;
|
|
10
21
|
}): Promise<ArrayBuffer>;
|
|
22
|
+
/**
|
|
23
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
24
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
|
|
25
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
26
|
+
*
|
|
27
|
+
* @param params url and action
|
|
28
|
+
*/
|
|
29
|
+
export declare function getPresignedUrlForZ3Url(this: SDKResource, params: {
|
|
30
|
+
url: string;
|
|
31
|
+
action: Z3GetPresignedUrlParams['action'];
|
|
32
|
+
}): Promise<Z3GetPresignedUrlResponse>;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { __awaiter } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { defaultProjectApiUrl } from '../../client/client.js';
|
|
3
|
+
import { OystehrSdkError } from '../../errors/index.js';
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
7
|
+
*
|
|
8
|
+
* @param params upload file params
|
|
9
|
+
*/
|
|
3
10
|
function uploadFile({ bucketName, 'objectPath+': key, file, }) {
|
|
4
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5
12
|
const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
|
|
@@ -13,6 +20,11 @@ function uploadFile({ bucketName, 'objectPath+': key, file, }) {
|
|
|
13
20
|
});
|
|
14
21
|
});
|
|
15
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
25
|
+
*
|
|
26
|
+
* @param params download file params
|
|
27
|
+
*/
|
|
16
28
|
function downloadFile({ bucketName, 'objectPath+': key, }) {
|
|
17
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
30
|
const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
|
|
@@ -29,6 +41,42 @@ function downloadFile({ bucketName, 'objectPath+': key, }) {
|
|
|
29
41
|
return resp.arrayBuffer();
|
|
30
42
|
});
|
|
31
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
46
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
|
|
47
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
48
|
+
*
|
|
49
|
+
* @param params url and action
|
|
50
|
+
*/
|
|
51
|
+
function getPresignedUrlForZ3Url(params) {
|
|
52
|
+
var _a;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
let bucket;
|
|
55
|
+
let key;
|
|
56
|
+
const url = new URL(params.url);
|
|
57
|
+
if (url.protocol === 'z3:') {
|
|
58
|
+
// remove leading forward slash
|
|
59
|
+
const z3PathParts = url.pathname.split('/').slice(1);
|
|
60
|
+
bucket = url.hostname;
|
|
61
|
+
key = z3PathParts.join('/');
|
|
62
|
+
}
|
|
63
|
+
else if (url.href.startsWith((_a = this.config.projectApiUrl) !== null && _a !== void 0 ? _a : defaultProjectApiUrl)) {
|
|
64
|
+
// remove leading `/v1/z3`
|
|
65
|
+
const httpsPathParts = url.pathname.split('/').slice(3);
|
|
66
|
+
bucket = httpsPathParts[0];
|
|
67
|
+
key = httpsPathParts.slice(1).join('/');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });
|
|
71
|
+
}
|
|
72
|
+
const requestParams = {
|
|
73
|
+
action: 'upload',
|
|
74
|
+
bucketName: bucket,
|
|
75
|
+
'objectPath+': key,
|
|
76
|
+
};
|
|
77
|
+
return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
32
80
|
|
|
33
|
-
export { downloadFile, uploadFile };
|
|
81
|
+
export { downloadFile, getPresignedUrlForZ3Url, uploadFile };
|
|
34
82
|
//# sourceMappingURL=z3-ext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"z3-ext.js","sources":["../../../../src/resources/classes/z3-ext.ts"],"sourcesContent":["import { SDKResource } from '../../client/client';\n\nexport async function uploadFile(\n this: SDKResource,\n {\n bucketName,\n 'objectPath+': key,\n file,\n }: {\n bucketName: string;\n 'objectPath+': string;\n file: Blob;\n }\n): Promise<void> {\n const uploadUrl = await this.request(\n '/z3/{bucketName}/{objectPath+}',\n 'post'\n )({\n action: 'upload',\n bucketName,\n 'objectPath+': key,\n });\n await fetch(uploadUrl.signedUrl, {\n method: 'PUT',\n body: file,\n });\n}\n\nexport async function downloadFile(\n this: SDKResource,\n {\n bucketName,\n 'objectPath+': key,\n }: {\n bucketName: string;\n 'objectPath+': string;\n }\n): Promise<ArrayBuffer> {\n const uploadUrl = await this.request(\n '/z3/{bucketName}/{objectPath+}',\n 'post'\n )({\n action: 'download',\n bucketName,\n 'objectPath+': key,\n });\n const resp = await fetch(uploadUrl.signedUrl, {\n method: 'GET',\n });\n if (!resp.ok) {\n throw new Error('Failed to download file');\n }\n return resp.arrayBuffer();\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"z3-ext.js","sources":["../../../../src/resources/classes/z3-ext.ts"],"sourcesContent":["import { defaultProjectApiUrl, SDKResource } from '../../client/client';\nimport { OystehrSdkError } from '../../errors';\nimport { Z3GetPresignedUrlParams, Z3GetPresignedUrlResponse } from '../types';\n\n/**\n * Uploads a file to the bucket and key. Files should be Blobs.\n *\n * @param params upload file params\n */\nexport async function uploadFile(\n this: SDKResource,\n {\n bucketName,\n 'objectPath+': key,\n file,\n }: {\n bucketName: string;\n 'objectPath+': string;\n file: Blob;\n }\n): Promise<void> {\n const uploadUrl = await this.request(\n '/z3/{bucketName}/{objectPath+}',\n 'post'\n )({\n action: 'upload',\n bucketName,\n 'objectPath+': key,\n });\n await fetch(uploadUrl.signedUrl, {\n method: 'PUT',\n body: file,\n });\n}\n\n/**\n * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.\n *\n * @param params download file params\n */\nexport async function downloadFile(\n this: SDKResource,\n {\n bucketName,\n 'objectPath+': key,\n }: {\n bucketName: string;\n 'objectPath+': string;\n }\n): Promise<ArrayBuffer> {\n const uploadUrl = await this.request(\n '/z3/{bucketName}/{objectPath+}',\n 'post'\n )({\n action: 'download',\n bucketName,\n 'objectPath+': key,\n });\n const resp = await fetch(uploadUrl.signedUrl, {\n method: 'GET',\n });\n if (!resp.ok) {\n throw new Error('Failed to download file');\n }\n return resp.arrayBuffer();\n}\n\n/**\n * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms\n * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`\n * instead of the standard SDK `Z3GetPresignedUrlParams`.\n *\n * @param params url and action\n */\nexport async function getPresignedUrlForZ3Url(\n this: SDKResource,\n params: { url: string; action: Z3GetPresignedUrlParams['action'] }\n): Promise<Z3GetPresignedUrlResponse> {\n let bucket: string;\n let key: string;\n const url = new URL(params.url);\n if (url.protocol === 'z3:') {\n // remove leading forward slash\n const z3PathParts = url.pathname.split('/').slice(1);\n bucket = url.hostname;\n key = z3PathParts.join('/');\n } else if (url.href.startsWith(this.config.projectApiUrl ?? defaultProjectApiUrl)) {\n // remove leading `/v1/z3`\n const httpsPathParts = url.pathname.split('/').slice(3);\n bucket = httpsPathParts[0];\n key = httpsPathParts.slice(1).join('/');\n } else {\n throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });\n }\n const requestParams: Z3GetPresignedUrlParams = {\n action: 'upload',\n bucketName: bucket,\n 'objectPath+': key,\n };\n return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACG,SAAgB,UAAU,CAE9B,EACE,UAAU,EACV,aAAa,EAAE,GAAG,EAClB,IAAI,GAKL,EAAA;;QAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAClC,gCAAgC,EAChC,MAAM,CACP,CAAC;AACA,YAAA,MAAM,EAAE,QAAQ;YAChB,UAAU;AACV,YAAA,aAAa,EAAE,GAAG;AACnB,SAAA,CAAC,CAAC;AACH,QAAA,MAAM,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE;AAC/B,YAAA,MAAM,EAAE,KAAK;AACb,YAAA,IAAI,EAAE,IAAI;AACX,SAAA,CAAC,CAAC;KACJ,CAAA,CAAA;AAAA,CAAA;AAED;;;;AAIG;AACG,SAAgB,YAAY,CAEhC,EACE,UAAU,EACV,aAAa,EAAE,GAAG,GAInB,EAAA;;QAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAClC,gCAAgC,EAChC,MAAM,CACP,CAAC;AACA,YAAA,MAAM,EAAE,UAAU;YAClB,UAAU;AACV,YAAA,aAAa,EAAE,GAAG;AACnB,SAAA,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE;AAC5C,YAAA,MAAM,EAAE,KAAK;AACd,SAAA,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BAAgB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACrE,SAAA;AACD,QAAA,MAAM,aAAa,GAA4B;AAC7C,YAAA,MAAM,EAAE,QAAQ;AAChB,YAAA,UAAU,EAAE,MAAM;AAClB,YAAA,aAAa,EAAE,GAAG;SACnB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;;AAC9E;;;;"}
|
|
@@ -4,8 +4,23 @@ import { OystehrConfig } from '../../config';
|
|
|
4
4
|
import * as ext from './z3-ext';
|
|
5
5
|
export declare class Z3 extends SDKResource {
|
|
6
6
|
constructor(config: OystehrConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
9
|
+
* @param params upload file params
|
|
10
|
+
*/
|
|
7
11
|
uploadFile: typeof ext.uploadFile;
|
|
12
|
+
/**
|
|
13
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
14
|
+
* @param params download file params
|
|
15
|
+
*/
|
|
8
16
|
downloadFile: typeof ext.downloadFile;
|
|
17
|
+
/**
|
|
18
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
19
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
|
|
20
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
21
|
+
* @param params url and action
|
|
22
|
+
*/
|
|
23
|
+
getPresignedUrlForZ3Url: typeof ext.getPresignedUrlForZ3Url;
|
|
9
24
|
/**
|
|
10
25
|
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
|
|
11
26
|
*
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client.js';
|
|
2
|
-
import { uploadFile, downloadFile } from './z3-ext.js';
|
|
2
|
+
import { uploadFile, downloadFile, getPresignedUrlForZ3Url } from './z3-ext.js';
|
|
3
3
|
|
|
4
4
|
// AUTOGENERATED -- DO NOT EDIT
|
|
5
5
|
class Z3 extends SDKResource {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
super(config);
|
|
8
|
+
/**
|
|
9
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
10
|
+
* @param params upload file params
|
|
11
|
+
*/
|
|
8
12
|
this.uploadFile = uploadFile;
|
|
13
|
+
/**
|
|
14
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
15
|
+
* @param params download file params
|
|
16
|
+
*/
|
|
9
17
|
this.downloadFile = downloadFile;
|
|
18
|
+
/**
|
|
19
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
20
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
|
|
21
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
22
|
+
* @param params url and action
|
|
23
|
+
*/
|
|
24
|
+
this.getPresignedUrlForZ3Url = getPresignedUrlForZ3Url;
|
|
10
25
|
/**
|
|
11
26
|
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
|
|
12
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"z3.js","sources":["../../../../src/resources/classes/z3.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n Z3CreateBucketParams,\n Z3CreateBucketResponse,\n Z3DeleteBucketParams,\n Z3DeleteObjectParams,\n Z3GetPresignedUrlParams,\n Z3GetPresignedUrlResponse,\n Z3ListBucketsResponse,\n Z3ListObjectsParams,\n Z3ListObjectsResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './z3-ext';\n\nexport class Z3 extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n uploadFile = ext.uploadFile;\n downloadFile = ext.downloadFile;\n /**\n * List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:ListBuckets`\n * Access Policy Resource: `Z3:BucketName`\n */\n listBuckets = (request?: OystehrClientRequest): Promise<Z3ListBucketsResponse> => this.request('/z3', 'get')(request);\n /**\n * Create a Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:CreateBucket`\n * Access Policy Resource: `Z3:BucketName`\n */\n createBucket = (params: Z3CreateBucketParams, request?: OystehrClientRequest): Promise<Z3CreateBucketResponse> =>\n this.request('/z3/{bucketName}', 'put')(params, request);\n /**\n * Delete the Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:DeleteBucket`\n * Access Policy Resource: `Z3:BucketName`\n */\n deleteBucket = (params: Z3DeleteBucketParams, request?: OystehrClientRequest): Promise<void> =>\n this.request('/z3/{bucketName}', 'delete')(params, request);\n /**\n * List all Z3 Objects at the provided path in the Bucket with the provided name [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:ListObjects`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n listObjects = (params: Z3ListObjectsParams, request?: OystehrClientRequest): Promise<Z3ListObjectsResponse> =>\n this.request('/z3/{bucketName}/{objectPath+}', 'get')(params, request);\n /**\n * Get a link for downloading or uploading a Z3 Object to the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:PutObject` or `Z3:GetObject`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n getPresignedUrl = (\n params: Z3GetPresignedUrlParams,\n request?: OystehrClientRequest\n ): Promise<Z3GetPresignedUrlResponse> => this.request('/z3/{bucketName}/{objectPath+}', 'post')(params, request);\n /**\n * Delete the Z3 Object at the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:DeleteObject`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n deleteObject = (params: Z3DeleteObjectParams, request?: OystehrClientRequest): Promise<void> =>\n this.request('/z3/{bucketName}/{objectPath+}', 'delete')(params, request);\n}\n"],"names":["ext.uploadFile","ext.downloadFile"],"mappings":";;;AAAA;AAkBM,MAAO,EAAG,SAAQ,WAAW,CAAA;AACjC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;AAEhB,QAAA,IAAA,CAAA,UAAU,GAAGA,UAAc,CAAC;AAC5B,QAAA,IAAA,CAAA,YAAY,GAAGC,YAAgB,CAAC;AAChC;;;;;AAKG;AACH,QAAA,IAAA,CAAA,WAAW,GAAG,CAAC,OAA8B,KAAqC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AACtH;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3D;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D;;;;;AAKG;QACH,IAAW,CAAA,WAAA,GAAG,CAAC,MAA2B,EAAE,OAA8B,KACxE,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzE;;;;;AAKG;QACH,IAAe,CAAA,eAAA,GAAG,CAChB,MAA+B,EAC/B,OAA8B,KACS,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjH;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"z3.js","sources":["../../../../src/resources/classes/z3.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n Z3CreateBucketParams,\n Z3CreateBucketResponse,\n Z3DeleteBucketParams,\n Z3DeleteObjectParams,\n Z3GetPresignedUrlParams,\n Z3GetPresignedUrlResponse,\n Z3ListBucketsResponse,\n Z3ListObjectsParams,\n Z3ListObjectsResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './z3-ext';\n\nexport class Z3 extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n /**\n * Uploads a file to the bucket and key. Files should be Blobs.\n * @param params upload file params\n */\n uploadFile = ext.uploadFile;\n /**\n * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.\n * @param params download file params\n */\n downloadFile = ext.downloadFile;\n /**\n * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms\n * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`\n * instead of the standard SDK `Z3GetPresignedUrlParams`.\n * @param params url and action\n */\n getPresignedUrlForZ3Url = ext.getPresignedUrlForZ3Url;\n /**\n * List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:ListBuckets`\n * Access Policy Resource: `Z3:BucketName`\n */\n listBuckets = (request?: OystehrClientRequest): Promise<Z3ListBucketsResponse> => this.request('/z3', 'get')(request);\n /**\n * Create a Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:CreateBucket`\n * Access Policy Resource: `Z3:BucketName`\n */\n createBucket = (params: Z3CreateBucketParams, request?: OystehrClientRequest): Promise<Z3CreateBucketResponse> =>\n this.request('/z3/{bucketName}', 'put')(params, request);\n /**\n * Delete the Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:DeleteBucket`\n * Access Policy Resource: `Z3:BucketName`\n */\n deleteBucket = (params: Z3DeleteBucketParams, request?: OystehrClientRequest): Promise<void> =>\n this.request('/z3/{bucketName}', 'delete')(params, request);\n /**\n * List all Z3 Objects at the provided path in the Bucket with the provided name [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:ListObjects`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n listObjects = (params: Z3ListObjectsParams, request?: OystehrClientRequest): Promise<Z3ListObjectsResponse> =>\n this.request('/z3/{bucketName}/{objectPath+}', 'get')(params, request);\n /**\n * Get a link for downloading or uploading a Z3 Object to the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:PutObject` or `Z3:GetObject`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n getPresignedUrl = (\n params: Z3GetPresignedUrlParams,\n request?: OystehrClientRequest\n ): Promise<Z3GetPresignedUrlResponse> => this.request('/z3/{bucketName}/{objectPath+}', 'post')(params, request);\n /**\n * Delete the Z3 Object at the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.\n *\n * Access Policy Action: `Z3:DeleteObject`\n * Access Policy Resource: `Z3:BucketName:ObjectPath`\n */\n deleteObject = (params: Z3DeleteObjectParams, request?: OystehrClientRequest): Promise<void> =>\n this.request('/z3/{bucketName}/{objectPath+}', 'delete')(params, request);\n}\n"],"names":["ext.uploadFile","ext.downloadFile","ext.getPresignedUrlForZ3Url"],"mappings":";;;AAAA;AAkBM,MAAO,EAAG,SAAQ,WAAW,CAAA;AACjC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;AAEhB;;;AAGG;AACH,QAAA,IAAA,CAAA,UAAU,GAAGA,UAAc,CAAC;AAC5B;;;AAGG;AACH,QAAA,IAAA,CAAA,YAAY,GAAGC,YAAgB,CAAC;AAChC;;;;;AAKG;AACH,QAAA,IAAA,CAAA,uBAAuB,GAAGC,uBAA2B,CAAC;AACtD;;;;;AAKG;AACH,QAAA,IAAA,CAAA,WAAW,GAAG,CAAC,OAA8B,KAAqC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AACtH;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3D;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D;;;;;AAKG;QACH,IAAW,CAAA,WAAA,GAAG,CAAC,MAA2B,EAAE,OAA8B,KACxE,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzE;;;;;AAKG;QACH,IAAe,CAAA,eAAA,GAAG,CAChB,MAA+B,EAC/B,OAA8B,KACS,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjH;;;;;AAKG;QACH,IAAY,CAAA,YAAA,GAAG,CAAC,MAA4B,EAAE,OAA8B,KAC1E,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAlE3E;AAmEF;;;;"}
|
|
@@ -7,6 +7,6 @@ export interface ZambdaCreateParams {
|
|
|
7
7
|
/**
|
|
8
8
|
* The trigger method for the Zambda Function determines how the Function is invoked. Learn more about the different types here, https://docs.oystehr.com/services/zambda/#types-of-zambdas.
|
|
9
9
|
*/
|
|
10
|
-
triggerMethod
|
|
10
|
+
triggerMethod?: 'http_auth' | 'http_open' | 'subscription' | 'cron';
|
|
11
11
|
schedule?: ZambdaSchedule;
|
|
12
12
|
}
|
|
@@ -2,10 +2,13 @@ import type { Operation } from 'fast-json-patch';
|
|
|
2
2
|
import type { Binary as BinaryR4B, Bundle as BundleR4B, BundleEntry as BundleEntryR4B, FhirResource as FhirResourceR4B, OperationOutcome as OperationOutcomeR4B } from 'fhir/r4b';
|
|
3
3
|
import type { Binary as BinaryR5, Bundle as BundleR5, BundleEntry as BundleEntryR5, FhirResource as FhirResourceR5, OperationOutcome as OperationOutcomeR5 } from 'fhir/r5';
|
|
4
4
|
export type FhirResource = FhirResourceR4B | FhirResourceR5;
|
|
5
|
-
export type FhirBundle<F extends FhirResource> = F extends FhirResourceR4B ?
|
|
6
|
-
export type
|
|
5
|
+
export type FhirBundle<F extends FhirResource> = F extends FhirResourceR4B ? BundleR4B<F> : BundleR5<F>;
|
|
6
|
+
export type EntrylessFhirBundle<F extends FhirResource> = F extends FhirResourceR4B ? Omit<BundleR4B<F>, 'entry'> : Omit<BundleR5<F>, 'entry'>;
|
|
7
|
+
export type Bundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
|
|
7
8
|
entry?: Array<BundleEntry<F>> | undefined;
|
|
8
|
-
unbundle: (this:
|
|
9
|
+
unbundle: (this: {
|
|
10
|
+
entry?: Array<BundleEntry<F>>;
|
|
11
|
+
}) => F[];
|
|
9
12
|
};
|
|
10
13
|
export type BundleEntry<F extends FhirResource> = F extends FhirResourceR4B ? BundleEntryR4B<F> : BundleEntryR5<F>;
|
|
11
14
|
export type Binary<F extends FhirResource> = F extends FhirResourceR4B ? BinaryR4B : BinaryR5;
|
package/package.json
CHANGED
package/src/client/client.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { OystehrFHIRError, OystehrSdkError } from '../errors';
|
|
|
4
4
|
import { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';
|
|
5
5
|
|
|
6
6
|
type HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';
|
|
7
|
-
const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';
|
|
7
|
+
export const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';
|
|
8
8
|
const defaultFhirApiUrl = 'https://fhir-api.zapehr.com';
|
|
9
9
|
const STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];
|
|
10
10
|
const ERROR_CODES_TO_RETRY = [
|
|
@@ -50,7 +50,7 @@ type FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;
|
|
|
50
50
|
export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;
|
|
51
51
|
|
|
52
52
|
export class SDKResource {
|
|
53
|
-
|
|
53
|
+
protected readonly config: OystehrConfig;
|
|
54
54
|
constructor(config: OystehrConfig) {
|
|
55
55
|
this.config = config;
|
|
56
56
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';
|
|
2
|
+
import { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';
|
|
1
3
|
import {
|
|
2
4
|
BatchInput,
|
|
3
5
|
BatchInputRequest,
|
|
@@ -61,7 +63,8 @@ export async function search<T extends FhirResource>(
|
|
|
61
63
|
});
|
|
62
64
|
const bundle: Bundle<T> = {
|
|
63
65
|
...requestBundle,
|
|
64
|
-
|
|
66
|
+
entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,
|
|
67
|
+
unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {
|
|
65
68
|
return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];
|
|
66
69
|
},
|
|
67
70
|
};
|
|
@@ -228,3 +231,68 @@ function bundleRequest(type: 'batch' | 'transaction') {
|
|
|
228
231
|
|
|
229
232
|
export const batch = bundleRequest('batch');
|
|
230
233
|
export const transaction = bundleRequest('transaction');
|
|
234
|
+
|
|
235
|
+
export function formatAddress(
|
|
236
|
+
address: AddressR4B | AddressR5,
|
|
237
|
+
options?: { all?: boolean; use?: boolean; lineSeparator?: string }
|
|
238
|
+
): string {
|
|
239
|
+
const builder = [];
|
|
240
|
+
|
|
241
|
+
if (address.line) {
|
|
242
|
+
builder.push(...address.line);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (address.city || address.state || address.postalCode) {
|
|
246
|
+
const cityStateZip = [];
|
|
247
|
+
if (address.city) {
|
|
248
|
+
cityStateZip.push(address.city);
|
|
249
|
+
}
|
|
250
|
+
if (address.state) {
|
|
251
|
+
cityStateZip.push(address.state);
|
|
252
|
+
}
|
|
253
|
+
if (address.postalCode) {
|
|
254
|
+
cityStateZip.push(address.postalCode);
|
|
255
|
+
}
|
|
256
|
+
builder.push(cityStateZip.join(', '));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (address.use && (options?.all || options?.use)) {
|
|
260
|
+
builder.push('[' + address.use + ']');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return builder.join(options?.lineSeparator || ', ').trim();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function formatHumanName(
|
|
267
|
+
name: HumanNameR4B | HumanNameR5,
|
|
268
|
+
options?: {
|
|
269
|
+
all?: boolean;
|
|
270
|
+
prefix?: boolean;
|
|
271
|
+
suffix?: boolean;
|
|
272
|
+
use?: boolean;
|
|
273
|
+
}
|
|
274
|
+
): string {
|
|
275
|
+
const builder = [];
|
|
276
|
+
|
|
277
|
+
if (name.prefix && options?.prefix !== false) {
|
|
278
|
+
builder.push(...name.prefix);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (name.given) {
|
|
282
|
+
builder.push(...name.given);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (name.family) {
|
|
286
|
+
builder.push(name.family);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (name.suffix && options?.suffix !== false) {
|
|
290
|
+
builder.push(...name.suffix);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (name.use && (options?.all || options?.use)) {
|
|
294
|
+
builder.push('[' + name.use + ']');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return builder.join(' ').trim();
|
|
298
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { SDKResource } from '../../client/client';
|
|
1
|
+
import { defaultProjectApiUrl, SDKResource } from '../../client/client';
|
|
2
|
+
import { OystehrSdkError } from '../../errors';
|
|
3
|
+
import { Z3GetPresignedUrlParams, Z3GetPresignedUrlResponse } from '../types';
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
7
|
+
*
|
|
8
|
+
* @param params upload file params
|
|
9
|
+
*/
|
|
3
10
|
export async function uploadFile(
|
|
4
11
|
this: SDKResource,
|
|
5
12
|
{
|
|
@@ -26,6 +33,11 @@ export async function uploadFile(
|
|
|
26
33
|
});
|
|
27
34
|
}
|
|
28
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
38
|
+
*
|
|
39
|
+
* @param params download file params
|
|
40
|
+
*/
|
|
29
41
|
export async function downloadFile(
|
|
30
42
|
this: SDKResource,
|
|
31
43
|
{
|
|
@@ -52,3 +64,38 @@ export async function downloadFile(
|
|
|
52
64
|
}
|
|
53
65
|
return resp.arrayBuffer();
|
|
54
66
|
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
70
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
|
|
71
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
72
|
+
*
|
|
73
|
+
* @param params url and action
|
|
74
|
+
*/
|
|
75
|
+
export async function getPresignedUrlForZ3Url(
|
|
76
|
+
this: SDKResource,
|
|
77
|
+
params: { url: string; action: Z3GetPresignedUrlParams['action'] }
|
|
78
|
+
): Promise<Z3GetPresignedUrlResponse> {
|
|
79
|
+
let bucket: string;
|
|
80
|
+
let key: string;
|
|
81
|
+
const url = new URL(params.url);
|
|
82
|
+
if (url.protocol === 'z3:') {
|
|
83
|
+
// remove leading forward slash
|
|
84
|
+
const z3PathParts = url.pathname.split('/').slice(1);
|
|
85
|
+
bucket = url.hostname;
|
|
86
|
+
key = z3PathParts.join('/');
|
|
87
|
+
} else if (url.href.startsWith(this.config.projectApiUrl ?? defaultProjectApiUrl)) {
|
|
88
|
+
// remove leading `/v1/z3`
|
|
89
|
+
const httpsPathParts = url.pathname.split('/').slice(3);
|
|
90
|
+
bucket = httpsPathParts[0];
|
|
91
|
+
key = httpsPathParts.slice(1).join('/');
|
|
92
|
+
} else {
|
|
93
|
+
throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });
|
|
94
|
+
}
|
|
95
|
+
const requestParams: Z3GetPresignedUrlParams = {
|
|
96
|
+
action: 'upload',
|
|
97
|
+
bucketName: bucket,
|
|
98
|
+
'objectPath+': key,
|
|
99
|
+
};
|
|
100
|
+
return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);
|
|
101
|
+
}
|
|
@@ -20,8 +20,23 @@ export class Z3 extends SDKResource {
|
|
|
20
20
|
constructor(config: OystehrConfig) {
|
|
21
21
|
super(config);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
25
|
+
* @param params upload file params
|
|
26
|
+
*/
|
|
23
27
|
uploadFile = ext.uploadFile;
|
|
28
|
+
/**
|
|
29
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
30
|
+
* @param params download file params
|
|
31
|
+
*/
|
|
24
32
|
downloadFile = ext.downloadFile;
|
|
33
|
+
/**
|
|
34
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
35
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
|
|
36
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
37
|
+
* @param params url and action
|
|
38
|
+
*/
|
|
39
|
+
getPresignedUrlForZ3Url = ext.getPresignedUrlForZ3Url;
|
|
25
40
|
/**
|
|
26
41
|
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
|
|
27
42
|
*
|