@solibo/solibo-query 1.7.84 → 1.8.0

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,13 +1,20 @@
1
1
  import { SoliboSDK } from "@solibo/solibo-sdk";
2
2
  import { Id } from "../../../utils/kt-bridge.js";
3
+ type ShowCommunicationReportParams = Parameters<SoliboSDK["api"]["communication"]["showCommunicationReport"]>;
4
+ type CommunicationReportCommunicationType = ShowCommunicationReportParams[1];
5
+ type CommunicationReportReportChannel = ShowCommunicationReportParams[3];
6
+ type CommunicationReportMessageType = ShowCommunicationReportParams[4];
3
7
  export declare function communicationReportQueryOptions(sdk: SoliboSDK, params: {
4
8
  companyId?: Id | null | undefined;
5
- communicationType?: string | null | undefined;
9
+ communicationType?: CommunicationReportCommunicationType | null | undefined;
6
10
  communicationId?: Id | null | undefined;
7
- reportType?: string | null | undefined;
11
+ reportChannel?: CommunicationReportReportChannel | null | undefined;
12
+ reportType?: CommunicationReportReportChannel | null | undefined;
13
+ messageType?: CommunicationReportMessageType | null | undefined;
8
14
  fields?: string;
9
15
  }): {
10
- queryKey: (string | readonly ["communication", "report", string | number | null | undefined, string | null | undefined, string | number | null | undefined, string | null | undefined] | undefined)[];
16
+ queryKey: (string | readonly ["communication", "report", string | number | null | undefined, string | null | undefined, string | number | null | undefined, string | null | undefined] | null | undefined)[];
11
17
  queryFn: () => Promise<import("@solibo/solibo-sdk").CommunicationReport>;
12
18
  enabled: boolean;
13
19
  };
20
+ export {};
@@ -1,18 +1,33 @@
1
1
  import { fromKt } from "../../../utils/kt-bridge.js";
2
2
  import { communicationKeys } from "./newsletters.js";
3
+ function toCommunicationReportKeyValue(value) {
4
+ if (value == null || typeof value === "string") {
5
+ return value;
6
+ }
7
+ const candidate = value;
8
+ if (typeof candidate.value === "string") {
9
+ return candidate.value;
10
+ }
11
+ if (typeof candidate.name === "string") {
12
+ return candidate.name;
13
+ }
14
+ return String(value);
15
+ }
3
16
  export function communicationReportQueryOptions(sdk, params) {
17
+ const reportChannel = params.reportChannel ?? params.reportType;
4
18
  return {
5
19
  queryKey: [
6
- communicationKeys.report(params.companyId, params.communicationType, params.communicationId, params.reportType),
20
+ communicationKeys.report(params.companyId, toCommunicationReportKeyValue(params.communicationType), params.communicationId, toCommunicationReportKeyValue(reportChannel)),
21
+ toCommunicationReportKeyValue(params.messageType),
7
22
  params.fields,
8
23
  ],
9
24
  queryFn: () => sdk.api.communication
10
- .showCommunicationReport(BigInt(params.companyId).valueOf(), params.communicationType, BigInt(params.communicationId).valueOf(), params.reportType, params.fields)
25
+ .showCommunicationReport(BigInt(params.companyId).valueOf(), params.communicationType, BigInt(params.communicationId).valueOf(), reportChannel, params.messageType, params.fields)
11
26
  .then((res) => fromKt(res.body())),
12
27
  enabled: !!params.companyId &&
13
28
  !!params.communicationType &&
14
29
  !!params.communicationId &&
15
- !!params.reportType,
30
+ !!reportChannel,
16
31
  };
17
32
  }
18
33
  //# sourceMappingURL=communicationReport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"communicationReport.js","sourceRoot":"","sources":["../../../../src/api/queries/communication/communicationReport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAM,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,UAAU,+BAA+B,CAC7C,GAAc,EACd,MAMC;IAED,OAAO;QACL,QAAQ,EAAE;YACR,iBAAiB,CAAC,MAAM,CACtB,MAAM,CAAC,SAAU,EACjB,MAAM,CAAC,iBAAkB,EACzB,MAAM,CAAC,eAAgB,EACvB,MAAM,CAAC,UAAW,CACnB;YACD,MAAM,CAAC,MAAM;SACd;QACD,OAAO,EAAE,GAAG,EAAE,CACZ,GAAG,CAAC,GAAG,CAAC,aAAa;aAClB,uBAAuB,CACtB,MAAM,CAAC,MAAM,CAAC,SAAU,CAAC,CAAC,OAAO,EAAE,EACnC,MAAM,CAAC,iBAAkB,EACzB,MAAM,CAAC,MAAM,CAAC,eAAgB,CAAC,CAAC,OAAO,EAAE,EACzC,MAAM,CAAC,UAAW,EAClB,MAAM,CAAC,MAAM,CACd;aACA,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,EACL,CAAC,CAAC,MAAM,CAAC,SAAS;YAClB,CAAC,CAAC,MAAM,CAAC,iBAAiB;YAC1B,CAAC,CAAC,MAAM,CAAC,eAAe;YACxB,CAAC,CAAC,MAAM,CAAC,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { SoliboSDK } from \"@solibo/solibo-sdk\";\nimport { fromKt, Id } from \"../../../utils/kt-bridge.js\";\nimport { communicationKeys } from \"./newsletters.js\";\n\nexport function communicationReportQueryOptions(\n sdk: SoliboSDK,\n params: {\n companyId?: Id | null | undefined;\n communicationType?: string | null | undefined;\n communicationId?: Id | null | undefined;\n reportType?: string | null | undefined;\n fields?: string;\n },\n) {\n return {\n queryKey: [\n communicationKeys.report(\n params.companyId!,\n params.communicationType!,\n params.communicationId!,\n params.reportType!,\n ),\n params.fields,\n ],\n queryFn: () =>\n sdk.api.communication\n .showCommunicationReport(\n BigInt(params.companyId!).valueOf(),\n params.communicationType!,\n BigInt(params.communicationId!).valueOf(),\n params.reportType!,\n params.fields,\n )\n .then((res) => fromKt(res.body())),\n enabled:\n !!params.companyId &&\n !!params.communicationType &&\n !!params.communicationId &&\n !!params.reportType,\n };\n}\n"]}
1
+ {"version":3,"file":"communicationReport.js","sourceRoot":"","sources":["../../../../src/api/queries/communication/communicationReport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAM,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,SAAS,6BAA6B,CACpC,KAKa;IAEb,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EA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AM,CAAC,eAAe;YACxB,CAAC,CAAC,aAAa;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import { SoliboSDK } from \"@solibo/solibo-sdk\";\nimport { fromKt, Id } from \"../../../utils/kt-bridge.js\";\nimport { communicationKeys } from \"./newsletters.js\";\n\ntype ShowCommunicationReportParams = Parameters<\n SoliboSDK[\"api\"][\"communication\"][\"showCommunicationReport\"]\n>;\n\ntype CommunicationReportCommunicationType = ShowCommunicationReportParams[1];\ntype CommunicationReportReportChannel = ShowCommunicationReportParams[3];\ntype CommunicationReportMessageType = ShowCommunicationReportParams[4];\n\nfunction toCommunicationReportKeyValue(\n value:\n | CommunicationReportCommunicationType\n | CommunicationReportReportChannel\n | CommunicationReportMessageType\n | null\n | undefined,\n) {\n if (value == null || typeof value === \"string\") {\n return value;\n }\n\n const candidate = value as { value?: unknown; name?: unknown };\n\n if (typeof candidate.value === \"string\") {\n return candidate.value;\n }\n\n if (typeof candidate.name === \"string\") {\n return candidate.name;\n }\n\n return String(value);\n}\n\nexport function communicationReportQueryOptions(\n sdk: SoliboSDK,\n params: {\n companyId?: Id | null | undefined;\n communicationType?: CommunicationReportCommunicationType | null | undefined;\n communicationId?: Id | null | undefined;\n reportChannel?: CommunicationReportReportChannel | null | undefined;\n reportType?: CommunicationReportReportChannel | null | undefined;\n messageType?: CommunicationReportMessageType | null | undefined;\n fields?: string;\n },\n) {\n const reportChannel = params.reportChannel ?? params.reportType;\n\n return {\n queryKey: [\n communicationKeys.report(\n params.companyId!,\n toCommunicationReportKeyValue(params.communicationType),\n params.communicationId!,\n toCommunicationReportKeyValue(reportChannel),\n ),\n toCommunicationReportKeyValue(params.messageType),\n params.fields,\n ],\n queryFn: () =>\n sdk.api.communication\n .showCommunicationReport(\n BigInt(params.companyId!).valueOf(),\n params.communicationType!,\n BigInt(params.communicationId!).valueOf(),\n reportChannel!,\n params.messageType,\n params.fields,\n )\n .then((res) => fromKt(res.body())),\n enabled:\n !!params.companyId &&\n !!params.communicationType &&\n !!params.communicationId &&\n !!reportChannel,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solibo/solibo-query",
3
- "version": "1.7.84",
3
+ "version": "1.8.0",
4
4
  "description": "Framework-agnostic TanStack Query options for Solibo SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "buffer": "^6.0.3",
21
21
  "hash-wasm": "^4.12.0",
22
22
  "mime-types": "^3.0.2",
23
- "@solibo/solibo-sdk": "1.7.84"
23
+ "@solibo/solibo-sdk": "1.8.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/js": "^10.0.1",