@contember/bindx-uploader 0.1.10 → 0.1.11
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,7 +1,7 @@
|
|
|
1
1
|
import { S3UploadClient, type S3UploadClientOptions } from '../uploadClient/S3UploadClient.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates an S3 upload client using the
|
|
4
|
-
*
|
|
3
|
+
* Creates an S3 upload client using the GraphQL client from bindx context.
|
|
4
|
+
* Requires ContemberBindxProvider (which provides graphQlClient).
|
|
5
5
|
*/
|
|
6
6
|
export declare const useS3Client: (options?: Partial<S3UploadClientOptions>) => S3UploadClient;
|
|
7
7
|
//# sourceMappingURL=useS3Client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useS3Client.d.ts","sourceRoot":"","sources":["../../src/hooks/useS3Client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAG9F;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,UAAS,OAAO,CAAC,qBAAqB,CAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"useS3Client.d.ts","sourceRoot":"","sources":["../../src/hooks/useS3Client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAG9F;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,UAAS,OAAO,CAAC,qBAAqB,CAAM,KAAG,cAa1E,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BindxGraphQlClient } from '@contember/bindx-react';
|
|
2
2
|
import type { S3FileParameters, S3SignedUrlResponse } from '../uploadClient/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an S3 URL signer that batches requests to reduce API calls.
|
|
5
5
|
* Uses microtask scheduling to batch concurrent signing requests into a single GraphQL mutation.
|
|
6
6
|
*/
|
|
7
|
-
export declare const createContentApiS3Signer: (client:
|
|
7
|
+
export declare const createContentApiS3Signer: (client: BindxGraphQlClient) => ((parameters: S3FileParameters) => Promise<S3SignedUrlResponse>);
|
|
8
8
|
//# sourceMappingURL=urlSigner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlSigner.d.ts","sourceRoot":"","sources":["../../src/utils/urlSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"urlSigner.d.ts","sourceRoot":"","sources":["../../src/utils/urlSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAErF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACpC,QAAQ,kBAAkB,KACxB,CAAC,CAAC,UAAU,EAAE,gBAAgB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAiCjE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/bindx-uploader",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "File upload components for bindx data binding",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
"react": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@contember/bindx": "0.1.
|
|
19
|
-
"@contember/bindx-react": "0.1.
|
|
20
|
-
"@contember/bindx-repeater": "0.1.
|
|
21
|
-
"@contember/graphql-client": "*",
|
|
18
|
+
"@contember/bindx": "0.1.11",
|
|
19
|
+
"@contember/bindx-react": "0.1.11",
|
|
20
|
+
"@contember/bindx-repeater": "0.1.11",
|
|
22
21
|
"@radix-ui/react-slot": "^1.2.3",
|
|
23
22
|
"react-dropzone": "^14.3.8"
|
|
24
23
|
},
|
package/src/hooks/useS3Client.ts
CHANGED
|
@@ -4,23 +4,20 @@ import { S3UploadClient, type S3UploadClientOptions } from '../uploadClient/S3Up
|
|
|
4
4
|
import { createContentApiS3Signer } from '../utils/urlSigner.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Creates an S3 upload client using the
|
|
8
|
-
*
|
|
7
|
+
* Creates an S3 upload client using the GraphQL client from bindx context.
|
|
8
|
+
* Requires ContemberBindxProvider (which provides graphQlClient).
|
|
9
9
|
*/
|
|
10
10
|
export const useS3Client = (options: Partial<S3UploadClientOptions> = {}): S3UploadClient => {
|
|
11
|
-
const {
|
|
11
|
+
const { graphQlClient } = useBindxContext()
|
|
12
12
|
|
|
13
13
|
return useMemo(() => {
|
|
14
|
-
// Get the GraphQL client from the adapter
|
|
15
|
-
// ContemberAdapter has a graphQlClient property
|
|
16
|
-
const graphQlClient = (adapter as { graphQlClient?: { execute: (query: string, options?: unknown) => Promise<unknown> } }).graphQlClient
|
|
17
14
|
if (!graphQlClient) {
|
|
18
|
-
throw new Error('useS3Client requires
|
|
15
|
+
throw new Error('useS3Client requires ContemberBindxProvider (graphQlClient not available in context)')
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
return new S3UploadClient({
|
|
22
|
-
signUrl: createContentApiS3Signer(graphQlClient
|
|
19
|
+
signUrl: createContentApiS3Signer(graphQlClient),
|
|
23
20
|
...options,
|
|
24
21
|
})
|
|
25
|
-
}, [
|
|
22
|
+
}, [graphQlClient, options])
|
|
26
23
|
}
|
package/src/utils/urlSigner.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BindxGraphQlClient } from '@contember/bindx-react'
|
|
2
2
|
import type { S3FileParameters, S3SignedUrlResponse } from '../uploadClient/types.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import type { S3FileParameters, S3SignedUrlResponse } from '../uploadClient/type
|
|
|
6
6
|
* Uses microtask scheduling to batch concurrent signing requests into a single GraphQL mutation.
|
|
7
7
|
*/
|
|
8
8
|
export const createContentApiS3Signer = (
|
|
9
|
-
client:
|
|
9
|
+
client: BindxGraphQlClient,
|
|
10
10
|
): ((parameters: S3FileParameters) => Promise<S3SignedUrlResponse>) => {
|
|
11
11
|
let uploadUrlBatchParameters: S3FileParameters[] = []
|
|
12
12
|
let uploadUrlBatchResult: null | Promise<Record<string, S3SignedUrlResponse>> = null
|