synapse-react-client 4.0.43 → 4.0.44
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/SWC.index.js +1 -1
- package/dist/components/DataGrid/DataGridWebSocket.d.ts +29 -1
- package/dist/components/DataGrid/DataGridWebSocket.d.ts.map +1 -1
- package/dist/components/DataGrid/DataGridWebSocket.js +48 -16
- package/dist/components/DataGrid/DataGridWebSocket.js.map +1 -1
- package/dist/components/DataGrid/components/GridLoadingState.d.ts +2 -2
- package/dist/components/DataGrid/components/GridLoadingState.d.ts.map +1 -1
- package/dist/components/DataGrid/components/GridLoadingState.js +2 -2
- package/dist/components/DataGrid/components/GridLoadingState.js.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.d.ts.map +1 -1
- package/dist/components/DataGrid/useDataGridWebsocket.js +2 -1
- package/dist/components/DataGrid/useDataGridWebsocket.js.map +1 -1
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.d.ts.map +1 -1
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.js +11 -10
- package/dist/components/EntityViewScopeEditor/EntityViewMaskEditor.js.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.d.ts +10 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.d.ts.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.js +81 -0
- package/dist/components/SetManagedAccessRequirementFields/DataUseCertificateFields.js.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.d.ts +9 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.d.ts.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.js +32 -0
- package/dist/components/SetManagedAccessRequirementFields/ExpirationPeriodField.js.map +1 -0
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts +0 -2
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js +74 -151
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js.map +1 -1
- package/dist/components/TanStackTable/TanStackTableUtils.d.ts.map +1 -1
- package/dist/components/TanStackTable/TanStackTableUtils.js +8 -5
- package/dist/components/TanStackTable/TanStackTableUtils.js.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.d.ts +5 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.d.ts.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.js +20 -0
- package/dist/components/dataaccess/SubmissionPage/DataAccessSubmissionFileHandleLink.js.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.d.ts.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.js +183 -188
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.js.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.d.ts +25 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.d.ts.map +1 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.js +125 -0
- package/dist/components/dataaccess/SubmissionPage/SubmissionSchemaAnswers.js.map +1 -0
- package/dist/mocks/dataaccess/MockSubmission.d.ts +76 -0
- package/dist/mocks/dataaccess/MockSubmission.d.ts.map +1 -1
- package/dist/mocks/dataaccess/MockSubmission.js +108 -63
- package/dist/mocks/dataaccess/MockSubmission.js.map +1 -1
- package/dist/style/components/_submission-page.scss +0 -4
- package/dist/style/main.css +1 -1
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.d.ts +37 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.d.ts.map +1 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.js +35 -0
- package/dist/synapse-queries/dataaccess/useGeneratedSubmissionForm.js.map +1 -0
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.d.ts +2 -0
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.d.ts.map +1 -1
- package/dist/synapse-queries/grid/useEstablishWebsocketConnection.js.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.d.ts.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.js +21 -19
- package/dist/synapse-queries/termsOfService/useTermsOfService.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/functions/EntityTypeUtils.d.ts +2 -2
- package/dist/utils/functions/EntityTypeUtils.d.ts.map +1 -1
- package/dist/utils/functions/EntityTypeUtils.js +135 -135
- package/dist/utils/functions/EntityTypeUtils.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GeneratedFormSchemaForRjsf } from '@/utils/jsonschema/generateDataAccessSchema';
|
|
2
|
+
import { RJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { FormTemplateReference } from '@sage-bionetworks/synapse-client';
|
|
4
|
+
import { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError';
|
|
5
|
+
import { Submission } from '@sage-bionetworks/synapse-types';
|
|
6
|
+
/**
|
|
7
|
+
* A Submission that carries the FormTemplate it was made against.
|
|
8
|
+
*
|
|
9
|
+
* PLFM-10009 will expose this reference; until then it is read from this field, which only mock
|
|
10
|
+
* data populates.
|
|
11
|
+
*/
|
|
12
|
+
export type SubmissionWithFormTemplateRef = Submission & {
|
|
13
|
+
formTemplateRef?: FormTemplateReference;
|
|
14
|
+
};
|
|
15
|
+
export declare class MissingFormTemplateRefError extends Error {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The FormTemplate version in effect when the submission was created, as opposed to the one its
|
|
20
|
+
* Access Requirement currently references.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSubmissionFormTemplateRef(submission: Submission | undefined): FormTemplateReference | undefined;
|
|
23
|
+
export type GeneratedSubmissionForm = GeneratedFormSchemaForRjsf & {
|
|
24
|
+
/** The template's registered JSON Schema, used to label answers outside the generated steps. */
|
|
25
|
+
schema: RJSFSchema;
|
|
26
|
+
};
|
|
27
|
+
export type GeneratedSubmissionFormResult = {
|
|
28
|
+
form: GeneratedSubmissionForm | undefined;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: SynapseClientError | MissingFormTemplateRefError | undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Generate the read-only form for a submission's `schemaData` from the FormTemplate version the
|
|
34
|
+
* submission was made against. Idle when the submission has no `schemaData`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useGeneratedSubmissionForm(submission: Submission | undefined): GeneratedSubmissionFormResult;
|
|
37
|
+
//# sourceMappingURL=useGeneratedSubmissionForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGeneratedSubmissionForm.d.ts","sourceRoot":"","sources":["../../../src/synapse-queries/dataaccess/useGeneratedSubmissionForm.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAE3B,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAEL,qBAAqB,EACtB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0DAA0D,CAAA;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAG5D;;;;;GAKG;AACH,MAAM,MAAM,6BAA6B,GAAG,UAAU,GAAG;IACvD,eAAe,CAAC,EAAE,qBAAqB,CAAA;CACxC,CAAA;AAED,qBAAa,2BAA4B,SAAQ,KAAK;;CAIrD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,qBAAqB,GAAG,SAAS,CAGnC;AAED,MAAM,MAAM,uBAAuB,GAAG,0BAA0B,GAAG;IACjE,gGAAgG;IAChG,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,uBAAuB,GAAG,SAAS,CAAA;IACzC,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,kBAAkB,GAAG,2BAA2B,GAAG,SAAS,CAAA;CACpE,CAAA;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,6BAA6B,CAuC/B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useGetFormTemplateVersion as e } from "./useFormTemplate.js";
|
|
2
|
+
import { useGetRegisteredSchema as t } from "../jsonschema/useSchema.js";
|
|
3
|
+
import { generateDataAccessSchema as n } from "../../utils/jsonschema/generateDataAccessSchema.js";
|
|
4
|
+
import { useMemo as r } from "react";
|
|
5
|
+
import { DataAccessRequestType as i } from "@sage-bionetworks/synapse-client";
|
|
6
|
+
//#region src/synapse-queries/dataaccess/useGeneratedSubmissionForm.ts
|
|
7
|
+
var a = class extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("The form template used for this submission could not be determined.");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function o(e) {
|
|
13
|
+
return e?.formTemplateRef;
|
|
14
|
+
}
|
|
15
|
+
function s(s) {
|
|
16
|
+
let c = s?.schemaData != null, l = o(s), u = e(c ? l?.templateId : void 0, l?.templateVersionNumber), d = u.data?.schema$id, f = t(d ?? "", { enabled: !!d }), p = u.data, m = f.data, h = s?.isRenewalSubmission ?? !1, g = r(() => {
|
|
17
|
+
if (!(!p || !m)) return {
|
|
18
|
+
...n(p, m, h ? i.RENEWAL : i.REQUEST),
|
|
19
|
+
schema: m
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
p,
|
|
23
|
+
m,
|
|
24
|
+
h
|
|
25
|
+
]), _ = c && !l;
|
|
26
|
+
return {
|
|
27
|
+
form: g,
|
|
28
|
+
isLoading: c && !_ && (u.isLoading || f.isLoading),
|
|
29
|
+
error: _ ? new a() : u.error ?? f.error ?? void 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { a as MissingFormTemplateRefError, o as getSubmissionFormTemplateRef, s as useGeneratedSubmissionForm };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=useGeneratedSubmissionForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGeneratedSubmissionForm.js","names":[],"sources":["../../../src/synapse-queries/dataaccess/useGeneratedSubmissionForm.ts"],"sourcesContent":["import { useGetFormTemplateVersion } from '@/synapse-queries/dataaccess/useFormTemplate'\nimport { useGetRegisteredSchema } from '@/synapse-queries/jsonschema/useSchema'\nimport {\n GeneratedFormSchemaForRjsf,\n generateDataAccessSchema,\n} from '@/utils/jsonschema/generateDataAccessSchema'\nimport { RJSFSchema } from '@rjsf/utils'\nimport {\n DataAccessRequestType,\n FormTemplateReference,\n} from '@sage-bionetworks/synapse-client'\nimport { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'\nimport { Submission } from '@sage-bionetworks/synapse-types'\nimport { useMemo } from 'react'\n\n/**\n * A Submission that carries the FormTemplate it was made against.\n *\n * PLFM-10009 will expose this reference; until then it is read from this field, which only mock\n * data populates.\n */\nexport type SubmissionWithFormTemplateRef = Submission & {\n formTemplateRef?: FormTemplateReference\n}\n\nexport class MissingFormTemplateRefError extends Error {\n constructor() {\n super('The form template used for this submission could not be determined.')\n }\n}\n\n/**\n * The FormTemplate version in effect when the submission was created, as opposed to the one its\n * Access Requirement currently references.\n */\nexport function getSubmissionFormTemplateRef(\n submission: Submission | undefined,\n): FormTemplateReference | undefined {\n return (submission as SubmissionWithFormTemplateRef | undefined)\n ?.formTemplateRef\n}\n\nexport type GeneratedSubmissionForm = GeneratedFormSchemaForRjsf & {\n /** The template's registered JSON Schema, used to label answers outside the generated steps. */\n schema: RJSFSchema\n}\n\nexport type GeneratedSubmissionFormResult = {\n form: GeneratedSubmissionForm | undefined\n isLoading: boolean\n error: SynapseClientError | MissingFormTemplateRefError | undefined\n}\n\n/**\n * Generate the read-only form for a submission's `schemaData` from the FormTemplate version the\n * submission was made against. Idle when the submission has no `schemaData`.\n */\nexport function useGeneratedSubmissionForm(\n submission: Submission | undefined,\n): GeneratedSubmissionFormResult {\n const hasSchemaData = submission?.schemaData != null\n const templateRef = getSubmissionFormTemplateRef(submission)\n\n const templateQuery = useGetFormTemplateVersion(\n hasSchemaData ? templateRef?.templateId : undefined,\n templateRef?.templateVersionNumber,\n )\n const schemaId = templateQuery.data?.schema$id\n const schemaQuery = useGetRegisteredSchema(schemaId ?? '', {\n enabled: !!schemaId,\n })\n\n const template = templateQuery.data\n const schema = schemaQuery.data as RJSFSchema | undefined\n const isRenewalSubmission = submission?.isRenewalSubmission ?? false\n\n const form = useMemo<GeneratedSubmissionForm | undefined>(() => {\n if (!template || !schema) return undefined\n const requestType = isRenewalSubmission\n ? DataAccessRequestType.RENEWAL\n : DataAccessRequestType.REQUEST\n return {\n ...generateDataAccessSchema(template, schema, requestType),\n schema,\n }\n }, [template, schema, isRenewalSubmission])\n\n const missingTemplateRef = hasSchemaData && !templateRef\n return {\n form,\n isLoading:\n hasSchemaData &&\n !missingTemplateRef &&\n (templateQuery.isLoading || schemaQuery.isLoading),\n error: missingTemplateRef\n ? new MissingFormTemplateRefError()\n : (templateQuery.error ?? schemaQuery.error ?? undefined),\n }\n}\n"],"mappings":";;;;;;AAyBA,IAAa,IAAb,cAAiD,MAAM;CACrD,cAAc;EACZ,MAAM,qEAAqE;CAC7E;AACF;AAMA,SAAgB,EACd,GACmC;CACnC,OAAQ,GACJ;AACN;AAiBA,SAAgB,EACd,GAC+B;CAC/B,IAAM,IAAgB,GAAY,cAAc,MAC1C,IAAc,EAA6B,CAAU,GAErD,IAAgB,EACpB,IAAgB,GAAa,aAAa,KAAA,GAC1C,GAAa,qBACf,GACM,IAAW,EAAc,MAAM,WAC/B,IAAc,EAAuB,KAAY,IAAI,EACzD,SAAS,CAAC,CAAC,EACb,CAAC,GAEK,IAAW,EAAc,MACzB,IAAS,EAAY,MACrB,IAAsB,GAAY,uBAAuB,IAEzD,IAAO,QAAmD;EAC1D,OAAC,KAAY,CAAC,IAIlB,OAAO;GACL,GAAG,EAAyB,GAAU,GAJpB,IAChB,EAAsB,UACtB,EAAsB,OAEiC;GACzD;EACF;CACF,GAAG;EAAC;EAAU;EAAQ;CAAmB,CAAC,GAEpC,IAAqB,KAAiB,CAAC;CAC7C,OAAO;EACL;EACA,WACE,KACA,CAAC,MACA,EAAc,aAAa,EAAY;EAC1C,OAAO,IACH,IAAI,EAA4B,IAC/B,EAAc,SAAS,EAAY,SAAS,KAAA;CACnD;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataGridWebSocket } from '@/components/DataGrid/DataGridWebSocket';
|
|
2
2
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
3
3
|
import { GridModel } from '@/components/DataGrid/DataGridTypes';
|
|
4
|
+
import { CompactCodecPatch } from 'json-joy/lib/json-crdt-patch/codec/compact';
|
|
4
5
|
interface EstablishWebsocketParams {
|
|
5
6
|
replicaId: number;
|
|
6
7
|
sessionId: string;
|
|
@@ -13,6 +14,7 @@ interface EstablishWebsocketParams {
|
|
|
13
14
|
onSyncStart?: () => void;
|
|
14
15
|
onSyncEnd?: () => void;
|
|
15
16
|
model?: GridModel | null;
|
|
17
|
+
pendingPatches?: CompactCodecPatch[];
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEstablishWebsocketConnection.d.ts","sourceRoot":"","sources":["../../../src/synapse-queries/grid/useEstablishWebsocketConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EAAe,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"useEstablishWebsocketConnection.d.ts","sourceRoot":"","sources":["../../../src/synapse-queries/grid/useEstablishWebsocketConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EAAe,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAG9E,UAAU,wBAAwB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE;QACjB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;QACxB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;QACxC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;QAC1C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;QAC/B,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAA;QAClC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;QACxB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;QACtB,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;QACxB,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAA;KACrC,CAAA;CACF;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,CAAC,EAAE,OAAO,CACf,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,EAAE,wBAAwB,CAAC,CACzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEstablishWebsocketConnection.js","names":[],"sources":["../../../src/synapse-queries/grid/useEstablishWebsocketConnection.ts"],"sourcesContent":["import { useGridPresignedUrl } from '@/synapse-queries/grid/useGridPresignedUrl'\nimport { DataGridWebSocket } from '@/components/DataGrid/DataGridWebSocket'\nimport { useMutation, UseMutationOptions } from '@tanstack/react-query'\nimport { GridModel } from '@/components/DataGrid/DataGridTypes'\nimport { useCallback, useState } from 'react'\n\ninterface EstablishWebsocketParams {\n replicaId: number\n sessionId: string\n websocketOptions?: {\n onGridReady?: () => void\n onStatusChange?: (open: boolean) => void\n onModelCreate?: (model: GridModel) => void\n onReplicaConnected?: () => void\n onReplicaDisconnected?: () => void\n onSyncStart?: () => void\n onSyncEnd?: () => void\n model?: GridModel | null\n }\n}\n\n/**\n * Hook to establish a DataGrid WebSocket using a presigned URL.\n * Assumes the WebSocket will connect successfully once a presigned URL is retrieved.\n */\nexport function useEstablishWebsocketConnection(\n options?: Partial<\n UseMutationOptions<DataGridWebSocket, unknown, EstablishWebsocketParams>\n >,\n) {\n const { mutateAsync: fetchPresignedUrl } = useGridPresignedUrl()\n const [presignedUrl, setPresignedUrl] = useState<string | null>(null)\n\n const clearPresignedUrl = useCallback(() => {\n setPresignedUrl(null)\n }, [])\n\n const mutation = useMutation({\n retry: 5,\n retryDelay: attempt =>\n Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000),\n mutationFn: async ({\n replicaId,\n sessionId,\n websocketOptions,\n }: EstablishWebsocketParams) => {\n if (!replicaId) throw new Error('replicaId is required')\n const url = await fetchPresignedUrl({ replicaId, sessionId })\n setPresignedUrl(url)\n\n return new DataGridWebSocket({\n replicaId,\n url,\n ...(websocketOptions || {}),\n })\n },\n ...options,\n })\n\n return { ...mutation, presignedUrl, clearPresignedUrl }\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useEstablishWebsocketConnection.js","names":[],"sources":["../../../src/synapse-queries/grid/useEstablishWebsocketConnection.ts"],"sourcesContent":["import { useGridPresignedUrl } from '@/synapse-queries/grid/useGridPresignedUrl'\nimport { DataGridWebSocket } from '@/components/DataGrid/DataGridWebSocket'\nimport { useMutation, UseMutationOptions } from '@tanstack/react-query'\nimport { GridModel } from '@/components/DataGrid/DataGridTypes'\nimport { CompactCodecPatch } from 'json-joy/lib/json-crdt-patch/codec/compact'\nimport { useCallback, useState } from 'react'\n\ninterface EstablishWebsocketParams {\n replicaId: number\n sessionId: string\n websocketOptions?: {\n onGridReady?: () => void\n onStatusChange?: (open: boolean) => void\n onModelCreate?: (model: GridModel) => void\n onReplicaConnected?: () => void\n onReplicaDisconnected?: () => void\n onSyncStart?: () => void\n onSyncEnd?: () => void\n model?: GridModel | null\n pendingPatches?: CompactCodecPatch[]\n }\n}\n\n/**\n * Hook to establish a DataGrid WebSocket using a presigned URL.\n * Assumes the WebSocket will connect successfully once a presigned URL is retrieved.\n */\nexport function useEstablishWebsocketConnection(\n options?: Partial<\n UseMutationOptions<DataGridWebSocket, unknown, EstablishWebsocketParams>\n >,\n) {\n const { mutateAsync: fetchPresignedUrl } = useGridPresignedUrl()\n const [presignedUrl, setPresignedUrl] = useState<string | null>(null)\n\n const clearPresignedUrl = useCallback(() => {\n setPresignedUrl(null)\n }, [])\n\n const mutation = useMutation({\n retry: 5,\n retryDelay: attempt =>\n Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000),\n mutationFn: async ({\n replicaId,\n sessionId,\n websocketOptions,\n }: EstablishWebsocketParams) => {\n if (!replicaId) throw new Error('replicaId is required')\n const url = await fetchPresignedUrl({ replicaId, sessionId })\n setPresignedUrl(url)\n\n return new DataGridWebSocket({\n replicaId,\n url,\n ...(websocketOptions || {}),\n })\n },\n ...options,\n })\n\n return { ...mutation, presignedUrl, clearPresignedUrl }\n}\n"],"mappings":";;;;;AA2BA,SAAgB,EACd,GAGA;CACA,IAAM,EAAE,aAAa,MAAsB,EAAoB,GACzD,CAAC,GAAc,KAAmB,EAAwB,IAAI,GAE9D,IAAoB,QAAkB;EAC1C,EAAgB,IAAI;CACtB,GAAG,CAAC,CAAC;CAwBL,OAAO;EAAE,GAtBQ,EAAY;GAC3B,OAAO;GACP,aAAY,MACV,KAAK,IAAI,IAAU,IAAI,KAAK,IAAU,MAAO,KAAM,KAAK,GAAI;GAC9D,YAAY,OAAO,EACjB,cACA,cACA,0BAC8B;IAC9B,IAAI,CAAC,GAAW,MAAU,MAAM,uBAAuB;IACvD,IAAM,IAAM,MAAM,EAAkB;KAAE;KAAW;IAAU,CAAC;IAG5D,OAFA,EAAgB,CAAG,GAEZ,IAAI,EAAkB;KAC3B;KACA;KACA,GAAI,KAAoB,CAAC;IAC3B,CAAC;GACH;GACA,GAAG;EACL,CAEY;EAAU;EAAc;CAAkB;AACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTermsOfService.d.ts","sourceRoot":"","sources":["../../../src/synapse-queries/termsOfService/useTermsOfService.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAA;AAC/D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAEL,kBAAkB,EAGlB,eAAe,EAChB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"useTermsOfService.d.ts","sourceRoot":"","sources":["../../../src/synapse-queries/termsOfService/useTermsOfService.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAA;AAC/D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAEL,kBAAkB,EAGlB,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAI9B,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,0FAS3E;AAED,wBAAgB,uBAAuB,CACrC,WAAW,CAAC,EAAE,MAAM,EAAE,4LAA4L;AAClN,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,4FAY7E;AAED,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,OAAO,CACf,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,CAAC,CAC7D,wGAmBF"}
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import e from "../../synapse-client/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { KeyFactory as t } from "../KeyFactory.js";
|
|
3
|
+
import { useSynapseContext as n } from "../../utils/context/SynapseContext.js";
|
|
3
4
|
import "../../utils/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { useMemo as r } from "react";
|
|
6
|
+
import { useMutation as i, useQuery as a, useQueryClient as o } from "@tanstack/react-query";
|
|
5
7
|
//#region src/synapse-queries/termsOfService/useTermsOfService.ts
|
|
6
|
-
function
|
|
7
|
-
let { accessToken:
|
|
8
|
-
return
|
|
9
|
-
...
|
|
10
|
-
queryKey:
|
|
11
|
-
queryFn: () => e.getTermsOfServiceInfo(
|
|
8
|
+
function s(t) {
|
|
9
|
+
let { accessToken: r, keyFactory: i } = n();
|
|
10
|
+
return a({
|
|
11
|
+
...t,
|
|
12
|
+
queryKey: i.getTermsOfServiceInfoKey(),
|
|
13
|
+
queryFn: () => e.getTermsOfServiceInfo(r)
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
return
|
|
16
|
+
function c(n, i) {
|
|
17
|
+
let o = r(() => new t(n), [n]);
|
|
18
|
+
return a({
|
|
17
19
|
...i,
|
|
18
|
-
queryKey:
|
|
20
|
+
queryKey: o.getTermsOfServiceStatus(),
|
|
19
21
|
queryFn: () => e.getTermsOfServiceStatus(n)
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
let { keyFactory:
|
|
24
|
-
return
|
|
25
|
-
...
|
|
24
|
+
function l(t) {
|
|
25
|
+
let { keyFactory: r } = n(), a = o();
|
|
26
|
+
return i({
|
|
27
|
+
...t,
|
|
26
28
|
mutationFn: (t) => e.signSynapseTermsOfUse(t),
|
|
27
|
-
onSuccess: async (e,
|
|
28
|
-
|
|
29
|
+
onSuccess: async (e, n, i) => {
|
|
30
|
+
await a.invalidateQueries({ queryKey: r.getTermsOfServiceStatus() }), t?.onSuccess && await t.onSuccess(e, n, i);
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
//#endregion
|
|
33
|
-
export {
|
|
35
|
+
export { l as useSignTermsOfService, s as useTermsOfServiceInfo, c as useTermsOfServiceStatus };
|
|
34
36
|
|
|
35
37
|
//# sourceMappingURL=useTermsOfService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTermsOfService.js","names":[],"sources":["../../../src/synapse-queries/termsOfService/useTermsOfService.ts"],"sourcesContent":["/*\n * Hooks to access Chat Services in Synapse\n */\nimport SynapseClient from '@/synapse-client'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport {\n AccessToken,\n TermsOfServiceInfo,\n TermsOfServiceStatus,\n} from '@sage-bionetworks/synapse-types'\nimport {\n useMutation,\n UseMutationOptions,\n useQuery,\n useQueryClient,\n UseQueryOptions,\n} from '@tanstack/react-query'\n\nexport function useTermsOfServiceInfo(\n options?: Partial<UseQueryOptions<TermsOfServiceInfo, SynapseClientError>>,\n) {\n const { accessToken, keyFactory } = useSynapseContext()\n return useQuery({\n ...options,\n queryKey: keyFactory.getTermsOfServiceInfoKey(),\n\n queryFn: () => SynapseClient.getTermsOfServiceInfo(accessToken),\n })\n}\n\nexport function useTermsOfServiceStatus(\n accessToken?: string, //usually we can fetch the access token from the context, but this hook is used by ApplicationSessionManager which sets the access token in the context (ApplicationSessionContextProvider)!\n options?: Partial<UseQueryOptions<TermsOfServiceStatus, SynapseClientError>>,\n) {\n const
|
|
1
|
+
{"version":3,"file":"useTermsOfService.js","names":[],"sources":["../../../src/synapse-queries/termsOfService/useTermsOfService.ts"],"sourcesContent":["/*\n * Hooks to access Chat Services in Synapse\n */\nimport SynapseClient from '@/synapse-client'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport {\n AccessToken,\n TermsOfServiceInfo,\n TermsOfServiceStatus,\n} from '@sage-bionetworks/synapse-types'\nimport {\n useMutation,\n UseMutationOptions,\n useQuery,\n useQueryClient,\n UseQueryOptions,\n} from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport { KeyFactory } from '../KeyFactory'\n\nexport function useTermsOfServiceInfo(\n options?: Partial<UseQueryOptions<TermsOfServiceInfo, SynapseClientError>>,\n) {\n const { accessToken, keyFactory } = useSynapseContext()\n return useQuery({\n ...options,\n queryKey: keyFactory.getTermsOfServiceInfoKey(),\n\n queryFn: () => SynapseClient.getTermsOfServiceInfo(accessToken),\n })\n}\n\nexport function useTermsOfServiceStatus(\n accessToken?: string, //usually we can fetch the access token from the context, but this hook is used by ApplicationSessionManager which sets the access token in the context (ApplicationSessionContextProvider)!\n options?: Partial<UseQueryOptions<TermsOfServiceStatus, SynapseClientError>>,\n) {\n const queryKeyFactory = useMemo(\n () => new KeyFactory(accessToken),\n [accessToken],\n )\n return useQuery({\n ...options,\n queryKey: queryKeyFactory.getTermsOfServiceStatus(),\n\n queryFn: () => SynapseClient.getTermsOfServiceStatus(accessToken),\n })\n}\n\nexport function useSignTermsOfService(\n options?: Partial<\n UseMutationOptions<unknown, SynapseClientError, AccessToken>\n >,\n) {\n const { keyFactory } = useSynapseContext()\n const queryClient = useQueryClient()\n return useMutation<unknown, SynapseClientError, AccessToken>({\n ...options,\n mutationFn: (accessToken: AccessToken) =>\n SynapseClient.signSynapseTermsOfUse(accessToken),\n onSuccess: async (resp, variables, ctx) => {\n // Wait for the refetch so that consumers redirecting in onSuccess see the updated status.\n // Otherwise, guards that check the (stale) status may send the user back to sign again.\n await queryClient.invalidateQueries({\n queryKey: keyFactory.getTermsOfServiceStatus(),\n })\n if (options?.onSuccess) {\n await options.onSuccess(resp, variables, ctx)\n }\n },\n })\n}\n"],"mappings":";;;;;;;AAoBA,SAAgB,EACd,GACA;CACA,IAAM,EAAE,gBAAa,kBAAe,EAAkB;CACtD,OAAO,EAAS;EACd,GAAG;EACH,UAAU,EAAW,yBAAyB;EAE9C,eAAe,EAAc,sBAAsB,CAAW;CAChE,CAAC;AACH;AAEA,SAAgB,EACd,GACA,GACA;CACA,IAAM,IAAkB,QAChB,IAAI,EAAW,CAAW,GAChC,CAAC,CAAW,CACd;CACA,OAAO,EAAS;EACd,GAAG;EACH,UAAU,EAAgB,wBAAwB;EAElD,eAAe,EAAc,wBAAwB,CAAW;CAClE,CAAC;AACH;AAEA,SAAgB,EACd,GAGA;CACA,IAAM,EAAE,kBAAe,EAAkB,GACnC,IAAc,EAAe;CACnC,OAAO,EAAsD;EAC3D,GAAG;EACH,aAAa,MACX,EAAc,sBAAsB,CAAW;EACjD,WAAW,OAAO,GAAM,GAAW,MAAQ;GAMzC,AAHA,MAAM,EAAY,kBAAkB,EAClC,UAAU,EAAW,wBAAwB,EAC/C,CAAC,GACG,GAAS,aACX,MAAM,EAAQ,UAAU,GAAM,GAAW,CAAG;EAEhD;CACF,CAAC;AACH"}
|