Membrane React - v0.6.0
    Preparing search index...

    Function useDataSourceInstance

    • Parameters

      Returns {
          dataSourceInstance:
              | undefined
              | {
                  id: string;
                  key?: string;
                  uuid?: string;
                  description?: string;
                  meta?: Record<string, any>;
                  name: string;
                  state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                  createdAt?: string;
                  updatedAt?: string;
                  archivedAt?: string;
                  isDeactivated?: boolean;
                  userId: string;
                  revision: string;
                  dataSourceRevision?: string;
                  dataSourceId?: string;
                  universalDataSourceId?: string;
                  udm?: string;
                  connectionId: string;
                  integrationId: string;
                  instanceKey?: string;
                  collectionKey?: string;
                  collectionParameters?: any;
                  defaultCollectionKey?: string;
                  defaultCollectionParameters?: any;
                  collectionSpec?: {
                      type: "collection";
                      key?: string;
                      name: string;
                      parametersSchema?: DataSchema;
                      fieldsSchema?: DataSchema;
                      list?: {
                          apiRequests?: { path: unknown; method: unknown }[];
                          filterFields?: string[];
                      };
                      search?: { apiRequests?: { path: unknown; method: unknown }[] };
                      match?: {
                          apiRequests?: { path: unknown; method: unknown }[];
                          fields?: string[];
                      };
                      findById?: { apiRequests?: { path: unknown; method: unknown }[] };
                      create?: {
                          apiRequests?: { path: unknown; method: unknown }[];
                          fields?: string[];
                          requiredFields?: string[];
                          excludedFields?: string[];
                      };
                      update?: {
                          apiRequests?: { path: unknown; method: unknown }[];
                          fields?: string[];
                          excludedFields?: string[];
                      };
                      delete?: { apiRequests?: { path: unknown; method: unknown }[] };
                      events?: {
                          created?: {
                              type: "push" | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                          updated?: {
                              type: "push"
                              | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                          deleted?: {
                              type: "push"
                              | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                          all?: {
                              type: "push"
                              | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                          [key: string]: {
                              type: "push"
                              | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                      };
                      customFields?: boolean;
                      udm?: Record<
                          string,
                          {
                              fields?: string[];
                              extract?: Record<string, any>;
                              parse?: Record<string, any>;
                          },
                      >;
                      find?: {
                          apiRequests?: { path: unknown; method: unknown }[];
                          queryFields?: string[];
                      };
                  };
                  isCustomized?: boolean;
                  errors?: ErrorDataSchema[];
                  pullUpdatesIntervalSeconds?: number;
                  fullSyncIntervalSeconds?: number;
                  path?: string;
                  defaultPath?: string;
                  user?: {
                      id: string;
                      name: string;
                      meta?: Record<string, any>;
                      internalId: string;
                      fields?: Record<string, any>;
                      credentials?: any;
                      lastActiveAt?: string;
                      isTest?: boolean;
                      isBillable?: boolean;
                      createdAt?: string;
                      archivedAt?: string;
                  };
                  dataSource?: {
                      id: string;
                      key?: string;
                      description?: string;
                      uuid?: string;
                      meta?: Record<string, any>;
                      integrationId?: string;
                      universalDataSourceId?: string;
                      udm?: string;
                      pullUpdatesIntervalSeconds?: number;
                      fullSyncIntervalSeconds?: number;
                      collectionKey?: string;
                      collectionParameters?: any;
                      defaultPath?: string;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      isCustomized?: boolean;
                      universalDataSourceRevision?: string;
                  };
                  connection?: {
                      id: string;
                      name: string;
                      userId: string;
                      isTest?: boolean;
                      disconnected?: boolean;
                      isDefunct?: boolean;
                      state?: CONFIGURATION_ERROR
                      | SETUP_FAILED
                      | READY;
                      error?: ErrorDataSchema;
                      integrationId: string;
                      authOptionKey?: string;
                      createdAt: string;
                      updatedAt: string;
                      lastActiveAt?: string;
                      nextCredentialsRefreshAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      meta?: Record<string, any>;
                  };
                  integration?: {
                      id: string;
                      key?: string;
                      uuid?: string;
                      description?: string;
                      meta?: Record<string, any>;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      logoUri: string;
                      connectorId?: string;
                      connectorVersion?: string;
                      oAuthCallbackUri?: string;
                      parameters?: any;
                      archivedAt?: string;
                      hasMissingParameters?: boolean;
                      hasDocumentation?: boolean;
                      hasOperations?: boolean;
                      operationsCount?: number;
                      hasData?: boolean;
                      dataCollectionsCount?: number;
                      hasEvents?: boolean;
                      eventsCount?: number;
                      hasGlobalWebhooks?: boolean;
                      hasUdm?: boolean;
                      isTest?: boolean;
                      appUuid?: string;
                      isDeactivated?: boolean;
                      authType?:
                          | "proxy"
                          | "integration-app-token"
                          | "membrane-token"
                          | "oauth2"
                          | "oauth1"
                          | "client-credentials";
                  };
              };
          accessor: undefined
          | DataSourceInstanceAccessor;
          refresh: () => Promise<
              {
                  id: string;
                  key?: string;
                  uuid?: string;
                  description?: string;
                  meta?: Record<string, any>;
                  name: string;
                  state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                  createdAt?: string;
                  updatedAt?: string;
                  archivedAt?: string;
                  isDeactivated?: boolean;
                  userId: string;
                  revision: string;
                  dataSourceRevision?: string;
                  dataSourceId?: string;
                  universalDataSourceId?: string;
                  udm?: string;
                  connectionId: string;
                  integrationId: string;
                  instanceKey?: string;
                  collectionKey?: string;
                  collectionParameters?: any;
                  defaultCollectionKey?: string;
                  defaultCollectionParameters?: any;
                  collectionSpec?: {
                      type: "collection";
                      key?: string;
                      name: string;
                      parametersSchema?: DataSchema;
                      fieldsSchema?: DataSchema;
                      list?: {
                          apiRequests?: { path: ...; method: ... }[];
                          filterFields?: string[];
                      };
                      search?: { apiRequests?: { path: ...; method: ... }[] };
                      match?: {
                          apiRequests?: { path: ...; method: ... }[];
                          fields?: string[];
                      };
                      findById?: { apiRequests?: { path: ...; method: ... }[] };
                      create?: {
                          apiRequests?: { path: ...; method: ... }[];
                          fields?: string[];
                          requiredFields?: string[];
                          excludedFields?: string[];
                      };
                      update?: {
                          apiRequests?: { path: ...; method: ... }[];
                          fields?: string[];
                          excludedFields?: string[];
                      };
                      delete?: { apiRequests?: { path: ...; method: ... }[] };
                      events?: {
                          created?: {
                              type: (...) | (...);
                              isFullScan?: (...) | (...) | (...);
                              isIdOnly?: (...) | (...) | (...);
                          };
                          updated?: {
                              type: (...)
                              | (...);
                              isFullScan?: (...) | (...) | (...);
                              isIdOnly?: (...) | (...) | (...);
                          };
                          deleted?: {
                              type: (...)
                              | (...);
                              isFullScan?: (...) | (...) | (...);
                              isIdOnly?: (...) | (...) | (...);
                          };
                          all?: {
                              type: (...)
                              | (...);
                              isFullScan?: (...) | (...) | (...);
                              isIdOnly?: (...) | (...) | (...);
                          };
                          [key: string]: {
                              type: "push"
                              | "pull";
                              isFullScan?: boolean;
                              isIdOnly?: boolean;
                          };
                      };
                      customFields?: boolean;
                      udm?: Record<
                          string,
                          {
                              fields?: (...)[];
                              extract?: Record<(...), (...)>;
                              parse?: Record<(...), (...)>;
                          },
                      >;
                      find?: {
                          apiRequests?: { path: ...; method: ... }[];
                          queryFields?: string[];
                      };
                  };
                  isCustomized?: boolean;
                  errors?: ErrorDataSchema[];
                  pullUpdatesIntervalSeconds?: number;
                  fullSyncIntervalSeconds?: number;
                  path?: string;
                  defaultPath?: string;
                  user?: {
                      id: string;
                      name: string;
                      meta?: Record<string, any>;
                      internalId: string;
                      fields?: Record<string, any>;
                      credentials?: any;
                      lastActiveAt?: string;
                      isTest?: boolean;
                      isBillable?: boolean;
                      createdAt?: string;
                      archivedAt?: string;
                  };
                  dataSource?: {
                      id: string;
                      key?: string;
                      description?: string;
                      uuid?: string;
                      meta?: Record<string, any>;
                      integrationId?: string;
                      universalDataSourceId?: string;
                      udm?: string;
                      pullUpdatesIntervalSeconds?: number;
                      fullSyncIntervalSeconds?: number;
                      collectionKey?: string;
                      collectionParameters?: any;
                      defaultPath?: string;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      isCustomized?: boolean;
                      universalDataSourceRevision?: string;
                  };
                  connection?: {
                      id: string;
                      name: string;
                      userId: string;
                      isTest?: boolean;
                      disconnected?: boolean;
                      isDefunct?: boolean;
                      state?: CONFIGURATION_ERROR
                      | SETUP_FAILED
                      | READY;
                      error?: ErrorDataSchema;
                      integrationId: string;
                      authOptionKey?: string;
                      createdAt: string;
                      updatedAt: string;
                      lastActiveAt?: string;
                      nextCredentialsRefreshAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      meta?: Record<string, any>;
                  };
                  integration?: {
                      id: string;
                      key?: string;
                      uuid?: string;
                      description?: string;
                      meta?: Record<string, any>;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      logoUri: string;
                      connectorId?: string;
                      connectorVersion?: string;
                      oAuthCallbackUri?: string;
                      parameters?: any;
                      archivedAt?: string;
                      hasMissingParameters?: boolean;
                      hasDocumentation?: boolean;
                      hasOperations?: boolean;
                      operationsCount?: number;
                      hasData?: boolean;
                      dataCollectionsCount?: number;
                      hasEvents?: boolean;
                      eventsCount?: number;
                      hasGlobalWebhooks?: boolean;
                      hasUdm?: boolean;
                      isTest?: boolean;
                      appUuid?: string;
                      isDeactivated?: boolean;
                      authType?:
                          | "proxy"
                          | "integration-app-token"
                          | "membrane-token"
                          | "oauth2"
                          | "oauth1"
                          | "client-credentials";
                  };
              },
          >;
          setup: () => Promise<void>;
          reset: () => Promise<void>;
          openConfiguration: (
              options?: OpenDataSourceConfigurationOptions,
          ) => Promise<undefined | void>;
          listRecords: (
              request?: {
                  parameters?: Record<string, any>;
                  filter?: any;
                  unifiedFilter?: any;
                  cursor?: string;
              },
          ) => Promise<
              | undefined
              | {
                  records: {
                      id: string;
                      name?: string;
                      uri?: string;
                      iconUri?: string;
                      fields?: Record<string, any>;
                      udm?: string;
                      unifiedFields?: Record<string, any>;
                      rawFields?: Record<string, any>;
                      createdTime?: string;
                      updatedTime?: string;
                      deletedTime?: string;
                      createdById?: string;
                      updatedById?: string;
                  }[];
                  drilldowns?: {
                      parameters?: Record<string, any>;
                      filter?: Record<string, any>;
                  }[];
                  cursor?: string;
              },
          >;
          findRecords: (
              request?: { query?: any; cursor?: string },
          ) => Promise<
              | undefined
              | {
                  records: {
                      id: string;
                      name?: string;
                      uri?: string;
                      iconUri?: string;
                      fields?: Record<string, any>;
                      udm?: string;
                      unifiedFields?: Record<string, any>;
                      rawFields?: Record<string, any>;
                      createdTime?: string;
                      updatedTime?: string;
                      deletedTime?: string;
                      createdById?: string;
                      updatedById?: string;
                  }[];
                  cursor?: string;
              },
          >;
          findRecordById: (
              id: string,
          ) => Promise<
              | undefined
              | {
                  record: {
                      id: string;
                      name?: string;
                      uri?: string;
                      iconUri?: string;
                      fields?: Record<string, any>;
                      udm?: string;
                      unifiedFields?: Record<string, any>;
                      rawFields?: Record<string, any>;
                      createdTime?: string;
                      updatedTime?: string;
                      deletedTime?: string;
                      createdById?: string;
                      updatedById?: string;
                  };
              },
          >;
          createRecord: (
              request?: {
                  parameters?: Record<string, any>;
                  fields: ZodRecord<ZodString, ZodAny>;
              },
          ) => Promise<undefined | { id: string }>;
          updateRecord: (
              request?: {
                  parameters?: Record<string, any>;
                  id: string;
                  fields: ZodRecord<ZodString, ZodAny>;
              },
          ) => Promise<undefined | { id: string }>;
          deleteRecord: (id?: string) => Promise<undefined | Record<string, never>>;
          unifiedFieldsToNative: (unifiedFields: any) => Promise<any>;
          getCollection: () => Promise<
              | undefined
              | {
                  type: "collection";
                  key?: string;
                  name: string;
                  parametersSchema?: DataSchema;
                  fieldsSchema?: DataSchema;
                  list?: {
                      apiRequests?: { path: unknown; method: unknown }[];
                      filterFields?: string[];
                  };
                  search?: { apiRequests?: { path: unknown; method: unknown }[] };
                  match?: {
                      apiRequests?: { path: unknown; method: unknown }[];
                      fields?: string[];
                  };
                  findById?: { apiRequests?: { path: unknown; method: unknown }[] };
                  create?: {
                      apiRequests?: { path: unknown; method: unknown }[];
                      fields?: string[];
                      requiredFields?: string[];
                      excludedFields?: string[];
                  };
                  update?: {
                      apiRequests?: { path: unknown; method: unknown }[];
                      fields?: string[];
                      excludedFields?: string[];
                  };
                  delete?: { apiRequests?: { path: unknown; method: unknown }[] };
                  events?: {
                      created?: {
                          type: "push" | "pull";
                          isFullScan?: boolean;
                          isIdOnly?: boolean;
                      };
                      updated?: {
                          type: "push"
                          | "pull";
                          isFullScan?: boolean;
                          isIdOnly?: boolean;
                      };
                      deleted?: {
                          type: "push"
                          | "pull";
                          isFullScan?: boolean;
                          isIdOnly?: boolean;
                      };
                      all?: {
                          type: "push"
                          | "pull";
                          isFullScan?: boolean;
                          isIdOnly?: boolean;
                      };
                      [key: string]: {
                          type: "push"
                          | "pull";
                          isFullScan?: boolean;
                          isIdOnly?: boolean;
                      };
                  };
                  customFields?: boolean;
                  udm?: Record<
                      string,
                      {
                          fields?: string[];
                          extract?: Record<string, any>;
                          parse?: Record<string, any>;
                      },
                  >;
                  find?: {
                      apiRequests?: { path: unknown; method: unknown }[];
                      queryFields?: string[];
                  };
              },
          >;
          loading: boolean;
          saving: boolean;
          error: any;
          refreshing: boolean;
          create: (
              data: { dataSourceId: string; connectionId: string; path?: string },
          ) => Promise<
              | undefined
              | {
                  id: string;
                  key?: string;
                  uuid?: string;
                  description?: string;
                  meta?: Record<string, any>;
                  name: string;
                  state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                  createdAt?: string;
                  updatedAt?: string;
                  archivedAt?: string;
                  isDeactivated?: boolean;
                  userId: string;
                  revision: string;
                  dataSourceRevision?: string;
                  dataSourceId?: string;
                  universalDataSourceId?: string;
                  udm?: string;
                  connectionId: string;
                  integrationId: string;
                  instanceKey?: string;
                  collectionKey?: string;
                  collectionParameters?: any;
                  defaultCollectionKey?: string;
                  defaultCollectionParameters?: any;
                  collectionSpec?: {
                      type: "collection";
                      key?: string;
                      name: string;
                      parametersSchema?: DataSchema;
                      fieldsSchema?: DataSchema;
                      list?: { apiRequests?: (...)[]; filterFields?: (...)[] };
                      search?: { apiRequests?: (...)[] };
                      match?: { apiRequests?: (...)[]; fields?: (...)[] };
                      findById?: { apiRequests?: (...)[] };
                      create?: {
                          apiRequests?: (...)[];
                          fields?: (...)[];
                          requiredFields?: (...)[];
                          excludedFields?: (...)[];
                      };
                      update?: {
                          apiRequests?: (...)[];
                          fields?: (...)[];
                          excludedFields?: (...)[];
                      };
                      delete?: { apiRequests?: (...)[] };
                      events?: {
                          created?: { type: ...; isFullScan?: ...; isIdOnly?: ... };
                          updated?: { type: ...; isFullScan?: ...; isIdOnly?: ... };
                          deleted?: { type: ...; isFullScan?: ...; isIdOnly?: ... };
                          all?: { type: ...; isFullScan?: ...; isIdOnly?: ... };
                          [key: string]: {
                              type: (...) | (...);
                              isFullScan?: (...) | (...) | (...);
                              isIdOnly?: (...) | (...) | (...);
                          };
                      };
                      customFields?: boolean;
                      udm?: Record<
                          string,
                          {
                              fields?: (...)
                              | (...);
                              extract?: (...) | (...);
                              parse?: (...) | (...);
                          },
                      >;
                      find?: { apiRequests?: (...)[]; queryFields?: (...)[] };
                  };
                  isCustomized?: boolean;
                  errors?: ErrorDataSchema[];
                  pullUpdatesIntervalSeconds?: number;
                  fullSyncIntervalSeconds?: number;
                  path?: string;
                  defaultPath?: string;
                  user?: {
                      id: string;
                      name: string;
                      meta?: Record<string, any>;
                      internalId: string;
                      fields?: Record<string, any>;
                      credentials?: any;
                      lastActiveAt?: string;
                      isTest?: boolean;
                      isBillable?: boolean;
                      createdAt?: string;
                      archivedAt?: string;
                  };
                  dataSource?: {
                      id: string;
                      key?: string;
                      description?: string;
                      uuid?: string;
                      meta?: Record<string, any>;
                      integrationId?: string;
                      universalDataSourceId?: string;
                      udm?: string;
                      pullUpdatesIntervalSeconds?: number;
                      fullSyncIntervalSeconds?: number;
                      collectionKey?: string;
                      collectionParameters?: any;
                      defaultPath?: string;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      isCustomized?: boolean;
                      universalDataSourceRevision?: string;
                  };
                  connection?: {
                      id: string;
                      name: string;
                      userId: string;
                      isTest?: boolean;
                      disconnected?: boolean;
                      isDefunct?: boolean;
                      state?: CONFIGURATION_ERROR
                      | SETUP_FAILED
                      | READY;
                      error?: ErrorDataSchema;
                      integrationId: string;
                      authOptionKey?: string;
                      createdAt: string;
                      updatedAt: string;
                      lastActiveAt?: string;
                      nextCredentialsRefreshAt?: string;
                      archivedAt?: string;
                      isDeactivated?: boolean;
                      meta?: Record<string, any>;
                  };
                  integration?: {
                      id: string;
                      key?: string;
                      uuid?: string;
                      description?: string;
                      meta?: Record<string, any>;
                      name: string;
                      state?: CONFIGURATION_ERROR | SETUP_FAILED | READY;
                      errors?: ErrorDataSchema[];
                      revision?: string;
                      createdAt?: string;
                      updatedAt?: string;
                      logoUri: string;
                      connectorId?: string;
                      connectorVersion?: string;
                      oAuthCallbackUri?: string;
                      parameters?: any;
                      archivedAt?: string;
                      hasMissingParameters?: boolean;
                      hasDocumentation?: boolean;
                      hasOperations?: boolean;
                      operationsCount?: number;
                      hasData?: boolean;
                      dataCollectionsCount?: number;
                      hasEvents?: boolean;
                      eventsCount?: number;
                      hasGlobalWebhooks?: boolean;
                      hasUdm?: boolean;
                      isTest?: boolean;
                      appUuid?: string;
                      isDeactivated?: boolean;
                      authType?:
                          | "proxy"
                          | "integration-app-token"
                          | "membrane-token"
                          | "oauth2"
                          | "oauth1"
                          | "client-credentials";
                  };
              },
          >;
          patch: (data: Partial<UpdateRequest>) => Promise<void>;
          put: (
              data: {
                  path?: string;
                  collectionKey?: string;
                  collectionParameters?: any;
                  pullUpdatesIntervalSeconds?: number;
                  fullSyncIntervalSeconds?: number;
                  subscribedTo?: {
                      created?: boolean;
                      updated?: boolean;
                      deleted?: boolean;
                  };
              },
          ) => Promise<void>;
          archive: () => Promise<void>;
      }