@resconet/qp-bridge 0.0.1-alpha.19 → 0.0.1-alpha.21

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.
@@ -126,6 +126,7 @@ export declare const mediaItemSchema: z.ZodObject<{
126
126
  mimeType: string;
127
127
  blobUrl: string;
128
128
  }>;
129
+ export declare const entitySchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
129
130
  export declare const groupSchema: z.ZodObject<{
130
131
  label: z.ZodString;
131
132
  hidden: z.ZodBoolean;
@@ -507,6 +508,136 @@ export declare const executeCustomCommandRequestMessageSchema: z.ZodObject<z.obj
507
508
  commandName: string;
508
509
  id?: string | undefined;
509
510
  }>;
511
+ export declare const fetchEntitiesRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
512
+ type: z.ZodLiteral<"qp-bridge">;
513
+ id: z.ZodOptional<z.ZodString>;
514
+ }, {
515
+ action: z.ZodLiteral<"fetchEntities">;
516
+ fetchXml: z.ZodString;
517
+ }>, "strip", z.ZodTypeAny, {
518
+ type: "qp-bridge";
519
+ action: "fetchEntities";
520
+ fetchXml: string;
521
+ id?: string | undefined;
522
+ }, {
523
+ type: "qp-bridge";
524
+ action: "fetchEntities";
525
+ fetchXml: string;
526
+ id?: string | undefined;
527
+ }>;
528
+ export declare const fetchEntitiesSuccessResponseMessageSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
529
+ type: z.ZodLiteral<"qp-bridge">;
530
+ id: z.ZodOptional<z.ZodString>;
531
+ }, {
532
+ status: z.ZodLiteral<"success">;
533
+ }>, {
534
+ entities: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
535
+ }>, "strip", z.ZodTypeAny, {
536
+ type: "qp-bridge";
537
+ status: "success";
538
+ entities: Record<string, unknown>[];
539
+ id?: string | undefined;
540
+ }, {
541
+ type: "qp-bridge";
542
+ status: "success";
543
+ entities: Record<string, unknown>[];
544
+ id?: string | undefined;
545
+ }>;
546
+ export declare const getEntityByIdRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
547
+ type: z.ZodLiteral<"qp-bridge">;
548
+ id: z.ZodOptional<z.ZodString>;
549
+ }, {
550
+ action: z.ZodLiteral<"getEntityById">;
551
+ entityName: z.ZodString;
552
+ entityId: z.ZodString;
553
+ }>, "strip", z.ZodTypeAny, {
554
+ type: "qp-bridge";
555
+ action: "getEntityById";
556
+ entityName: string;
557
+ entityId: string;
558
+ id?: string | undefined;
559
+ }, {
560
+ type: "qp-bridge";
561
+ action: "getEntityById";
562
+ entityName: string;
563
+ entityId: string;
564
+ id?: string | undefined;
565
+ }>;
566
+ export declare const getEntityByIdSuccessResponseMessageSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
567
+ type: z.ZodLiteral<"qp-bridge">;
568
+ id: z.ZodOptional<z.ZodString>;
569
+ }, {
570
+ status: z.ZodLiteral<"success">;
571
+ }>, {
572
+ entity: z.ZodRecord<z.ZodString, z.ZodUnknown>;
573
+ }>, "strip", z.ZodTypeAny, {
574
+ type: "qp-bridge";
575
+ status: "success";
576
+ entity: Record<string, unknown>;
577
+ id?: string | undefined;
578
+ }, {
579
+ type: "qp-bridge";
580
+ status: "success";
581
+ entity: Record<string, unknown>;
582
+ id?: string | undefined;
583
+ }>;
584
+ export declare const repeatGroupRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
585
+ type: z.ZodLiteral<"qp-bridge">;
586
+ id: z.ZodOptional<z.ZodString>;
587
+ }, {
588
+ action: z.ZodLiteral<"repeatGroup">;
589
+ parentGroupName: z.ZodString;
590
+ groupIndex: z.ZodNumber;
591
+ }>, "strip", z.ZodTypeAny, {
592
+ type: "qp-bridge";
593
+ action: "repeatGroup";
594
+ parentGroupName: string;
595
+ groupIndex: number;
596
+ id?: string | undefined;
597
+ }, {
598
+ type: "qp-bridge";
599
+ action: "repeatGroup";
600
+ parentGroupName: string;
601
+ groupIndex: number;
602
+ id?: string | undefined;
603
+ }>;
604
+ export declare const addNewGroupRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
605
+ type: z.ZodLiteral<"qp-bridge">;
606
+ id: z.ZodOptional<z.ZodString>;
607
+ }, {
608
+ action: z.ZodLiteral<"addNewGroup">;
609
+ groupName: z.ZodString;
610
+ }>, "strip", z.ZodTypeAny, {
611
+ type: "qp-bridge";
612
+ action: "addNewGroup";
613
+ groupName: string;
614
+ id?: string | undefined;
615
+ }, {
616
+ type: "qp-bridge";
617
+ action: "addNewGroup";
618
+ groupName: string;
619
+ id?: string | undefined;
620
+ }>;
621
+ export declare const deleteGroupRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
622
+ type: z.ZodLiteral<"qp-bridge">;
623
+ id: z.ZodOptional<z.ZodString>;
624
+ }, {
625
+ action: z.ZodLiteral<"deleteGroup">;
626
+ parentGroupName: z.ZodString;
627
+ groupIndex: z.ZodNumber;
628
+ }>, "strip", z.ZodTypeAny, {
629
+ type: "qp-bridge";
630
+ action: "deleteGroup";
631
+ parentGroupName: string;
632
+ groupIndex: number;
633
+ id?: string | undefined;
634
+ }, {
635
+ type: "qp-bridge";
636
+ action: "deleteGroup";
637
+ parentGroupName: string;
638
+ groupIndex: number;
639
+ id?: string | undefined;
640
+ }>;
510
641
  export type QpBridgeMessage = z.infer<typeof qpBridgeMessageSchema>;
511
642
  export type ResponseSuccessMessage = z.infer<typeof responseSuccessMessageSchema>;
512
643
  export type ResponseErrorMessage = z.infer<typeof responseErrorMessageSchema>;
@@ -515,10 +646,13 @@ export type QuestionOptional = z.infer<typeof questionOptionalScheme>;
515
646
  export type Group = z.infer<typeof groupSchema>;
516
647
  export type GroupOptional = z.infer<typeof groupOptionalScheme>;
517
648
  export type MediaItem = z.infer<typeof mediaItemSchema>;
649
+ export type Entity = z.infer<typeof entitySchema>;
518
650
  export type OnAnswerChangeMessage = z.infer<typeof onAnswerChangeMessageSchema>;
519
651
  export type GetQuestionSuccessResponseMessage = z.infer<typeof getQuestionSuccessResponseMessageSchema>;
520
652
  export type GetGroupSuccessResponseMessage = z.infer<typeof getGroupSuccessResponseMessageSchema>;
521
653
  export type CanSaveSuccessResponseMessage = z.infer<typeof canSaveSuccessResponseMessageSchema>;
654
+ export type FetchEntitiesSuccessResponseMessage = z.infer<typeof fetchEntitiesSuccessResponseMessageSchema>;
655
+ export type GetEntityByIdSuccessResponseMessage = z.infer<typeof getEntityByIdSuccessResponseMessageSchema>;
522
656
  export type SetAnswerRequestMessage = z.infer<typeof setAnswerRequestMessageSchema>;
523
657
  export type GetQuestionRequestMessage = z.infer<typeof getQuestionRequestMessageSchema>;
524
658
  export type GetGroupRequestMessage = z.infer<typeof getGroupRequestMessageSchema>;
@@ -530,6 +664,11 @@ export type SaveQuestionnaireRequestMessage = z.infer<typeof saveQuestionnaireRe
530
664
  export type CompleteAndCloseQuestionnaireRequestMessage = z.infer<typeof completeAndCloseQuestionnaireRequestMessageSchema>;
531
665
  export type ExecuteCustomCommandRequestMessage = z.infer<typeof executeCustomCommandRequestMessageSchema>;
532
666
  export type CanSaveRequestMessage = z.infer<typeof canSaveRequestMessageSchema>;
667
+ export type FetchEntitiesRequestMessage = z.infer<typeof fetchEntitiesRequestMessageSchema>;
668
+ export type GetEntityByIdRequestMessage = z.infer<typeof getEntityByIdRequestMessageSchema>;
669
+ export type RepeatGroupRequestMessage = z.infer<typeof repeatGroupRequestMessageSchema>;
670
+ export type AddNewGroupRequestMessage = z.infer<typeof addNewGroupRequestMessageSchema>;
671
+ export type DeleteGroupRequestMessage = z.infer<typeof deleteGroupRequestMessageSchema>;
533
672
  export type WithBusyIndicatorRequestMessage = BusyIndicatorStartRequestMessage | BusyIndicatorEndRequestMessage;
534
673
  export declare function isMediaItem(data: unknown): data is MediaItem;
535
674
  export declare function isOnAnswerChangeMessage(data: unknown): data is OnAnswerChangeMessage;
@@ -551,3 +690,10 @@ export declare function isSaveQuestionnaireRequestMessage(data: unknown): data i
551
690
  export declare function isCompleteAndCloseQuestionnaireRequestMessage(data: unknown): data is CompleteAndCloseQuestionnaireRequestMessage;
552
691
  export declare function isExecuteCustomCommandRequestMessage(data: unknown): data is ExecuteCustomCommandRequestMessage;
553
692
  export declare function isWithBusyIndicatorRequestMessage(data: unknown): data is WithBusyIndicatorRequestMessage;
693
+ export declare function isFetchEntitiesRequestMessage(data: unknown): data is FetchEntitiesRequestMessage;
694
+ export declare function isFetchEntitiesSuccessResponseMessage(data: unknown): data is FetchEntitiesSuccessResponseMessage;
695
+ export declare function isGetEntityByIdRequestMessage(data: unknown): data is GetEntityByIdRequestMessage;
696
+ export declare function isGetEntityByIdSuccessResponseMessage(data: unknown): data is GetEntityByIdSuccessResponseMessage;
697
+ export declare function isRepeatGroupRequestMessage(data: unknown): data is RepeatGroupRequestMessage;
698
+ export declare function isAddNewGroupRequestMessage(data: unknown): data is AddNewGroupRequestMessage;
699
+ export declare function isDeleteGroupRequestMessage(data: unknown): data is DeleteGroupRequestMessage;
@@ -1,4 +1,4 @@
1
- import { Group, GroupOptional, MediaItem, Question, QuestionOptional } from './qp-bridge-types';
1
+ import { Entity, Group, GroupOptional, MediaItem, Question, QuestionOptional } from './qp-bridge-types';
2
2
  /**
3
3
  * Creates a MediaItem from the provided parameters and content.
4
4
  *
@@ -232,4 +232,81 @@ type Validator = () => Promise<boolean>;
232
232
  export declare function onSave(validator: Validator): {
233
233
  cancelSubscription: () => void;
234
234
  };
235
+ /**
236
+ * Fetches entities from the CRM system using the provided FetchXML query.
237
+ *
238
+ * @param {string} fetchXml - The FetchXML query string to execute.
239
+ * @returns {Promise<Entity[]>} A promise that resolves to an array of entities.
240
+ * @throws {Error} Throws if the fetch operation fails or if no entities are found.
241
+ * @example
242
+ * ```typescript
243
+ * const fetchXml = `<fetch top="10">
244
+ * <entity name="contact">
245
+ * <attribute name="firstname" />
246
+ * <attribute name="lastname" />
247
+ * </entity>
248
+ * </fetch>`;
249
+ * const entities = await fetchEntities(fetchXml);
250
+ * console.log(entities); // Array of contact entities
251
+ * ```
252
+ */
253
+ export declare function fetchEntities(fetchXml: string): Promise<Entity[]>;
254
+ /**
255
+ * Retrieves a single entity by its name and ID from the CRM system.
256
+ *
257
+ * @param {string} entityName - The name of the entity to retrieve (e.g., "contact", "account").
258
+ * @param {string} id - The unique identifier of the entity.
259
+ * @returns {Promise<Entity>} A promise that resolves to the entity object.
260
+ * @throws {Error} Throws if the entity is not found or the operation fails.
261
+ * @example
262
+ * ```typescript
263
+ * const contact = await getEntityById('contact', '12345678-1234-1234-1234-123456789abc');
264
+ * console.log(contact.attributes.firstname); // Entity firstname attribute
265
+ * ```
266
+ */
267
+ export declare function getEntityById(entityName: string, id: string): Promise<Entity>;
268
+ /**
269
+ * Repeats a specific group within a repeatable group by creating a copy of the group at the specified index.
270
+ * The parent group must be a repeatable group and the index must refer to an existing group instance.
271
+ *
272
+ * @param {string} parentGroupName - The name of the parent repeatable group.
273
+ * @param {number} groupIndex - The index (0-based) of the group instance to repeat.
274
+ * @returns {Promise<void>} A promise that resolves when the group has been successfully repeated.
275
+ * @throws {Error} Throws if the parent group is not found, is not a repeatable group, the index is invalid, or the operation fails.
276
+ * @example
277
+ * ```typescript
278
+ * await repeatGroup('personalInfoRepeatable', 1);
279
+ * console.log('Group repeated successfully');
280
+ * ```
281
+ */
282
+ export declare function repeatGroup(parentGroupName: string, groupIndex: number): Promise<void>;
283
+ /**
284
+ * Adds a new group instance to a repeatable group.
285
+ * The specified name must refer to a repeatable group.
286
+ *
287
+ * @param {string} name - The name of the repeatable group to add a new instance to.
288
+ * @returns {Promise<void>} A promise that resolves when the new group has been successfully added.
289
+ * @throws {Error} Throws if the repeatable group is not found or the operation fails.
290
+ * @example
291
+ * ```typescript
292
+ * await addNewGroup('personalInfoRepeatable');
293
+ * console.log('New group added successfully');
294
+ * ```
295
+ */
296
+ export declare function addNewGroup(name: string): Promise<void>;
297
+ /**
298
+ * Deletes a specific group instance from a repeatable group by index.
299
+ * The parent group must be a repeatable group and the index must refer to an existing group instance.
300
+ *
301
+ * @param {string} parentGroupName - The name of the parent repeatable group.
302
+ * @param {number} groupIndex - The index (0-based) of the group instance to delete.
303
+ * @returns {Promise<void>} A promise that resolves when the group has been successfully deleted.
304
+ * @throws {Error} Throws if the parent group is not found, is not a repeatable group, the index is invalid, or the operation fails.
305
+ * @example
306
+ * ```typescript
307
+ * await deleteGroup('personalInfoRepeatable', 1);
308
+ * console.log('Group deleted successfully');
309
+ * ```
310
+ */
311
+ export declare function deleteGroup(parentGroupName: string, groupIndex: number): Promise<void>;
235
312
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resconet/qp-bridge",
3
- "version": "0.0.1-alpha.19",
3
+ "version": "0.0.1-alpha.21",
4
4
  "dependencies": {
5
5
  "zod": "^3.23.8",
6
6
  "uuid": "^9.0.1"