@wix/auto_sdk_benefit-programs_programs 1.0.21 → 1.0.22

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,3 +1,5 @@
1
+ import { NonNullablePaths } from '@wix/sdk-types';
2
+
1
3
  interface Program {
2
4
  /**
3
5
  * Program ID.
@@ -141,6 +143,8 @@ declare enum IdentityType {
141
143
  /** A Wix account holder, such as a site owner or contributor. */
142
144
  WIX_USER = "WIX_USER"
143
145
  }
146
+ /** @enumType */
147
+ type IdentityTypeWithLiterals = IdentityType | 'UNKNOWN' | 'ANONYMOUS_VISITOR' | 'MEMBER' | 'WIX_USER';
144
148
  interface ExtendedFields {
145
149
  /**
146
150
  * Extended field data. Each key corresponds to the namespace of the app that created the extended fields.
@@ -663,6 +667,66 @@ declare enum WebhookIdentityType {
663
667
  }
664
668
  /** @enumType */
665
669
  type WebhookIdentityTypeWithLiterals = WebhookIdentityType | 'UNKNOWN' | 'ANONYMOUS_VISITOR' | 'MEMBER' | 'WIX_USER' | 'APP';
670
+ type ProvisionProgramApplicationErrors = {
671
+ code?: 'PROGRAM_ALREADY_EXISTS';
672
+ description?: string;
673
+ data?: ProgramAlreadyExists;
674
+ } | {
675
+ code?: 'IN_PROGRESS';
676
+ description?: string;
677
+ data?: Record<string, any>;
678
+ };
679
+ type PauseProgramApplicationErrors = {
680
+ code?: 'PROGRAM_STATUS_TRANSITION_NOT_ALLOWED';
681
+ description?: string;
682
+ data?: ProgramStatusTransitionNotAllowed;
683
+ } | {
684
+ code?: 'ALREADY_EXECUTED';
685
+ description?: string;
686
+ data?: Record<string, any>;
687
+ } | {
688
+ code?: 'IN_PROGRESS';
689
+ description?: string;
690
+ data?: Record<string, any>;
691
+ };
692
+ type ResumeProgramApplicationErrors = {
693
+ code?: 'PROGRAM_STATUS_TRANSITION_NOT_ALLOWED';
694
+ description?: string;
695
+ data?: ProgramStatusTransitionNotAllowed;
696
+ } | {
697
+ code?: 'ALREADY_EXECUTED';
698
+ description?: string;
699
+ data?: Record<string, any>;
700
+ } | {
701
+ code?: 'IN_PROGRESS';
702
+ description?: string;
703
+ data?: Record<string, any>;
704
+ };
705
+ type EndProgramApplicationErrors = {
706
+ code?: 'PROGRAM_STATUS_TRANSITION_NOT_ALLOWED';
707
+ description?: string;
708
+ data?: ProgramStatusTransitionNotAllowed;
709
+ };
710
+ /**
711
+ * Creates a program for the specified beneficiary. Creating a program is also referred to as provisioning a program.
712
+ *
713
+ * You can provision a program from a program definition or a pool definition:
714
+ * - **Program definition**: The provisioned program has pools that are created from the pool definitions in the program definition.
715
+ * - **Pool definition**: The provisioned program has 1 pool that is created from the pool definition.
716
+ * @param poolDefinitionLookupId - The program definition or pool definition to use to provision the program.
717
+ * @public
718
+ * @documentationMaturity preview
719
+ * @requiredField options.beneficiary
720
+ * @requiredField options.externalProgramId
721
+ * @requiredField options.namespace
722
+ * @requiredField poolDefinitionLookupId
723
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_PROVISION
724
+ * @applicableIdentity APP
725
+ * @fqn wix.benefit_programs.v1.program.ProgramService.ProvisionProgram
726
+ */
727
+ declare function provisionProgram(poolDefinitionLookupId: PoolDefinitionLookupId, options?: NonNullablePaths<ProvisionProgramOptions, `beneficiary` | `externalProgramId` | `namespace`, 2>): Promise<NonNullablePaths<ProvisionProgramResponse, `jobId` | `program.status` | `program.beneficiary.anonymousVisitorId` | `program.beneficiary.memberId` | `program.beneficiary.wixUserId` | `program.programDefinition._id`, 4> & {
728
+ __applicationErrorsType?: ProvisionProgramApplicationErrors;
729
+ }>;
666
730
  interface ProvisionProgramOptions {
667
731
  /** Program beneficiary. */
668
732
  beneficiary: CommonIdentificationData;
@@ -691,6 +755,21 @@ interface ProvisionProgramOptions {
691
755
  */
692
756
  externalProgramId: string;
693
757
  }
758
+ /**
759
+ * Renews the specified program.
760
+ *
761
+ * The number of available credits in each pool in the program is defined in the corresponding pool's credit configuration.
762
+ * @param programId - ID of the program to renew.
763
+ * @public
764
+ * @documentationMaturity preview
765
+ * @requiredField options
766
+ * @requiredField options.idempotencyKey
767
+ * @requiredField programId
768
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_RENEW
769
+ * @applicableIdentity APP
770
+ * @fqn wix.benefit_programs.v1.program.ProgramService.RenewProgram
771
+ */
772
+ declare function renewProgram(programId: string, options: NonNullablePaths<RenewProgramOptions, `idempotencyKey`, 2>): Promise<NonNullablePaths<RenewProgramResponse, `jobId`, 2>>;
694
773
  interface RenewProgramOptions {
695
774
  /**
696
775
  * Idempotency key to ensure that the request is processed only once.
@@ -698,6 +777,21 @@ interface RenewProgramOptions {
698
777
  */
699
778
  idempotencyKey: string;
700
779
  }
780
+ /**
781
+ * Pauses the specified program. Benefits in the program's pools can't be redeemed until the program is resumed.
782
+ * @param programId - ID of the program to pause.
783
+ * @public
784
+ * @documentationMaturity preview
785
+ * @requiredField options
786
+ * @requiredField options.idempotencyKey
787
+ * @requiredField programId
788
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_PAUSE
789
+ * @applicableIdentity APP
790
+ * @fqn wix.benefit_programs.v1.program.ProgramService.PauseProgram
791
+ */
792
+ declare function pauseProgram(programId: string, options: NonNullablePaths<PauseProgramOptions, `idempotencyKey`, 2>): Promise<NonNullablePaths<PauseProgramResponse, `jobId`, 2> & {
793
+ __applicationErrorsType?: PauseProgramApplicationErrors;
794
+ }>;
701
795
  interface PauseProgramOptions {
702
796
  /**
703
797
  * Idempotency key to ensure that the request is processed only once.
@@ -705,6 +799,23 @@ interface PauseProgramOptions {
705
799
  */
706
800
  idempotencyKey: string;
707
801
  }
802
+ /**
803
+ * Resumes the specified program.
804
+ *
805
+ * Call this method for paused programs.
806
+ * @param programId - ID of program to resume.
807
+ * @public
808
+ * @documentationMaturity preview
809
+ * @requiredField options
810
+ * @requiredField options.idempotencyKey
811
+ * @requiredField programId
812
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_RESUME
813
+ * @applicableIdentity APP
814
+ * @fqn wix.benefit_programs.v1.program.ProgramService.ResumeProgram
815
+ */
816
+ declare function resumeProgram(programId: string, options: NonNullablePaths<ResumeProgramOptions, `idempotencyKey`, 2>): Promise<NonNullablePaths<ResumeProgramResponse, `jobId`, 2> & {
817
+ __applicationErrorsType?: ResumeProgramApplicationErrors;
818
+ }>;
708
819
  interface ResumeProgramOptions {
709
820
  /**
710
821
  * Idempotency key to ensure that the request is processed only once.
@@ -712,6 +823,39 @@ interface ResumeProgramOptions {
712
823
  */
713
824
  idempotencyKey: string;
714
825
  }
826
+ /**
827
+ * Ends the specified program.
828
+ * @param programId - ID of the program to end.
829
+ * @public
830
+ * @documentationMaturity preview
831
+ * @requiredField programId
832
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_END
833
+ * @applicableIdentity APP
834
+ * @fqn wix.benefit_programs.v1.program.ProgramService.EndProgram
835
+ */
836
+ declare function endProgram(programId: string): Promise<NonNullablePaths<EndProgramResponse, `jobId`, 2> & {
837
+ __applicationErrorsType?: EndProgramApplicationErrors;
838
+ }>;
839
+ /**
840
+ * Updates a program.
841
+ *
842
+ * Each time the program definition is updated,
843
+ * `revision` increments by 1.
844
+ * The current `revision` must be passed when updating the program definition.
845
+ * This ensures you're working with the latest program definition
846
+ * and prevents unintended overwrites.
847
+ * @param _id - Program ID.
848
+ * @public
849
+ * @documentationMaturity preview
850
+ * @requiredField _id
851
+ * @requiredField program
852
+ * @requiredField program.revision
853
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_UPDATE
854
+ * @applicableIdentity APP
855
+ * @returns Updated program.
856
+ * @fqn wix.benefit_programs.v1.program.ProgramService.UpdateProgram
857
+ */
858
+ declare function updateProgram(_id: string, program: NonNullablePaths<UpdateProgram, `revision`, 2>): Promise<NonNullablePaths<Program, `status` | `beneficiary.anonymousVisitorId` | `beneficiary.memberId` | `beneficiary.wixUserId` | `programDefinition._id`, 3>>;
715
859
  interface UpdateProgram {
716
860
  /**
717
861
  * Program ID.
@@ -790,6 +934,37 @@ interface UpdateProgram {
790
934
  */
791
935
  programDefinition?: ProgramDefinitionInfo;
792
936
  }
937
+ /**
938
+ * Retrieves a program.
939
+ * @param programId - ID of the program to retrieve.
940
+ * @public
941
+ * @documentationMaturity preview
942
+ * @requiredField programId
943
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_READ
944
+ * @applicableIdentity APP
945
+ * @returns Retrieved program.
946
+ * @fqn wix.benefit_programs.v1.program.ProgramService.GetProgram
947
+ */
948
+ declare function getProgram(programId: string): Promise<NonNullablePaths<Program, `status` | `beneficiary.anonymousVisitorId` | `beneficiary.memberId` | `beneficiary.wixUserId` | `programDefinition._id`, 3>>;
949
+ /**
950
+ * Creates a query to retrieve a list of programs.
951
+ *
952
+ * The Query Programs method builds a query to retrieve a list of programs and returns a `ProgramsQueryBuilder` object.
953
+ *
954
+ * The returned object contains the query definition, which is used to run the query using the `find()` method.
955
+ *
956
+ * You can refine the query by chaining `ProgramsQueryBuilder` methods onto the query. `ProgramsQueryBuilder` methods enable you to filter, sort, and control the results that Query Programs returns.
957
+ *
958
+ * Query Programs has a default paging limit of 50, which you can override.
959
+ *
960
+ * For a full description of the item object, see the object returned for the `items` property in `ProgramsQueryResult`.
961
+ * @public
962
+ * @documentationMaturity preview
963
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_READ
964
+ * @applicableIdentity APP
965
+ * @fqn wix.benefit_programs.v1.program.ProgramService.QueryPrograms
966
+ */
967
+ declare function queryPrograms(): ProgramsQueryBuilder;
793
968
  interface QueryCursorResult {
794
969
  cursors: Cursors;
795
970
  hasNext: () => boolean;
@@ -867,6 +1042,19 @@ interface ProgramsQueryBuilder {
867
1042
  /** @documentationMaturity preview */
868
1043
  find: () => Promise<ProgramsQueryResult>;
869
1044
  }
1045
+ /**
1046
+ * Retrieves a program with the specified external ID and namespace.
1047
+ * @param namespace - Namespace for your app or site's benefit programs. Namespaces allow you to distinguish between entities that you created and entities that other apps created.
1048
+ * @public
1049
+ * @documentationMaturity preview
1050
+ * @requiredField namespace
1051
+ * @requiredField options
1052
+ * @requiredField options.externalId
1053
+ * @permissionId BENEFIT_PROGRAMS.PROGRAM_READ
1054
+ * @applicableIdentity APP
1055
+ * @fqn wix.benefit_programs.v1.program.ProgramService.GetProgramByExternalIdAndNamespace
1056
+ */
1057
+ declare function getProgramByExternalIdAndNamespace(namespace: string, options: NonNullablePaths<GetProgramByExternalIdAndNamespaceOptions, `externalId`, 2>): Promise<NonNullablePaths<GetProgramByExternalIdAndNamespaceResponse, `program.status` | `program.beneficiary.anonymousVisitorId` | `program.beneficiary.memberId` | `program.beneficiary.wixUserId` | `program.programDefinition._id`, 4>>;
870
1058
  interface GetProgramByExternalIdAndNamespaceOptions {
871
1059
  /**
872
1060
  * Program's external ID.
@@ -875,4 +1063,4 @@ interface GetProgramByExternalIdAndNamespaceOptions {
875
1063
  externalId: string;
876
1064
  }
877
1065
 
878
- export { type Cursors as $, type ResumeProgramRequest as A, type EndProgramRequest as B, type CommonIdentificationData as C, type UpdateProgramStatusRequest as D, type EndProgramResponse as E, type UpdateProgramStatusResponse as F, type GetProgramByExternalIdAndNamespaceOptions as G, type UpsertMigratedProgramRequest as H, IdentityType as I, type UpsertMigratedProgramResponse as J, type UpdateProgramRequest as K, type UpdateProgramResponse as L, type GetProgramRequest as M, type GetProgramResponse as N, OrderStatus as O, type PoolDefinitionLookupId as P, type QueryProgramsRequest as Q, type RenewProgramOptions as R, SortOrder as S, type CursorQuery as T, type UpdateProgram as U, type CursorQueryPagingMethodOneOf as V, WebhookIdentityType as W, type Sorting as X, type CursorPaging as Y, type QueryProgramsResponse as Z, type CursorPagingMetadata as _, type ProvisionProgramOptions as a, type GetProgramByExternalIdAndNamespaceRequest as a0, type DomainEvent as a1, type DomainEventBodyOneOf as a2, type EntityCreatedEvent as a3, type RestoreInfo as a4, type EntityUpdatedEvent as a5, type EntityDeletedEvent as a6, type ActionEvent as a7, type MessageEnvelope as a8, type IdentificationData as a9, type IdentificationDataIdOneOf as aa, type ProgramsQueryResult as ab, type ProvisionProgramResponse as b, type RenewProgramResponse as c, type PauseProgramOptions as d, type PauseProgramResponse as e, type ResumeProgramOptions as f, type ResumeProgramResponse as g, type Program as h, type ProgramsQueryBuilder as i, type GetProgramByExternalIdAndNamespaceResponse as j, ProgramStatus as k, ProvisionProgramRequestProgramStatus as l, type CommonIdentificationDataIdOneOf as m, type ExtendedFields as n, type ProgramDefinitionInfo as o, type ProgramProvisioned as p, type ProgramRenewed as q, type ProgramEnded as r, type ProgramPaused as s, type ProgramResumed as t, type ProvisionProgramRequest as u, type PoolDefinitionLookupIdIdOneOf as v, type ProgramAlreadyExists as w, type RenewProgramRequest as x, type PauseProgramRequest as y, type ProgramStatusTransitionNotAllowed as z };
1066
+ export { type ActionEvent, type CommonIdentificationData, type CommonIdentificationDataIdOneOf, type CursorPaging, type CursorPagingMetadata, type CursorQuery, type CursorQueryPagingMethodOneOf, type Cursors, type DomainEvent, type DomainEventBodyOneOf, type EndProgramApplicationErrors, type EndProgramRequest, type EndProgramResponse, type EntityCreatedEvent, type EntityDeletedEvent, type EntityUpdatedEvent, type ExtendedFields, type GetProgramByExternalIdAndNamespaceOptions, type GetProgramByExternalIdAndNamespaceRequest, type GetProgramByExternalIdAndNamespaceResponse, type GetProgramRequest, type GetProgramResponse, type IdentificationData, type IdentificationDataIdOneOf, IdentityType, type IdentityTypeWithLiterals, type MessageEnvelope, OrderStatus, type OrderStatusWithLiterals, type PauseProgramApplicationErrors, type PauseProgramOptions, type PauseProgramRequest, type PauseProgramResponse, type PoolDefinitionLookupId, type PoolDefinitionLookupIdIdOneOf, type Program, type ProgramAlreadyExists, type ProgramDefinitionInfo, type ProgramEnded, type ProgramPaused, type ProgramProvisioned, type ProgramRenewed, type ProgramResumed, ProgramStatus, type ProgramStatusTransitionNotAllowed, type ProgramStatusWithLiterals, type ProgramsQueryBuilder, type ProgramsQueryResult, type ProvisionProgramApplicationErrors, type ProvisionProgramOptions, type ProvisionProgramRequest, ProvisionProgramRequestProgramStatus, type ProvisionProgramRequestProgramStatusWithLiterals, type ProvisionProgramResponse, type QueryProgramsRequest, type QueryProgramsResponse, type RenewProgramOptions, type RenewProgramRequest, type RenewProgramResponse, type RestoreInfo, type ResumeProgramApplicationErrors, type ResumeProgramOptions, type ResumeProgramRequest, type ResumeProgramResponse, SortOrder, type SortOrderWithLiterals, type Sorting, type UpdateProgram, type UpdateProgramRequest, type UpdateProgramResponse, type UpdateProgramStatusRequest, type UpdateProgramStatusResponse, type UpsertMigratedProgramRequest, type UpsertMigratedProgramResponse, WebhookIdentityType, type WebhookIdentityTypeWithLiterals, endProgram, getProgram, getProgramByExternalIdAndNamespace, pauseProgram, provisionProgram, queryPrograms, renewProgram, resumeProgram, updateProgram };