How to use the italia-ts-commons/lib/types.readonlySetType function in italia-ts-commons

To help you get started, we’ve selected a few italia-ts-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamdigitale / io-functions / lib / models / service.ts View on Github external
tag,
  withDefault
} from "italia-ts-commons/lib/types";
import { MaxAllowedPaymentAmount } from "../api/definitions/MaxAllowedPaymentAmount";

export const SERVICE_COLLECTION_NAME = "services";
export const SERVICE_MODEL_PK_FIELD = "serviceId";

/**
 * Base interface for Service objects
 */
export const Service = t.interface({
  // authorized source CIDRs
  authorizedCIDRs: readonlySetType(CIDR, "CIDRs"),
  // list of authorized fiscal codes
  authorizedRecipients: readonlySetType(FiscalCode, "fiscal codes"),
  // the name of the department within the service
  departmentName: NonEmptyString,
  // wether the service appears in the service list
  isVisible: withDefault(t.boolean, false),
  // maximum amount in euro cents that the service
  // can charge to a specific user (0 if the service cannot send payment requests)
  maxAllowedPaymentAmount: MaxAllowedPaymentAmount,
  // fiscal code of the organization, used to receive payments
  organizationFiscalCode: OrganizationFiscalCode,
  // the name of the organization
  organizationName: NonEmptyString,
  // this equals user's subscriptionId
  serviceId: NonEmptyString,
  // the name of the service
  serviceName: NonEmptyString
});
github teamdigitale / io-functions / lib / models / service.ts View on Github external
pick,
  readonlySetType,
  tag,
  withDefault
} from "italia-ts-commons/lib/types";
import { MaxAllowedPaymentAmount } from "../api/definitions/MaxAllowedPaymentAmount";

export const SERVICE_COLLECTION_NAME = "services";
export const SERVICE_MODEL_PK_FIELD = "serviceId";

/**
 * Base interface for Service objects
 */
export const Service = t.interface({
  // authorized source CIDRs
  authorizedCIDRs: readonlySetType(CIDR, "CIDRs"),
  // list of authorized fiscal codes
  authorizedRecipients: readonlySetType(FiscalCode, "fiscal codes"),
  // the name of the department within the service
  departmentName: NonEmptyString,
  // wether the service appears in the service list
  isVisible: withDefault(t.boolean, false),
  // maximum amount in euro cents that the service
  // can charge to a specific user (0 if the service cannot send payment requests)
  maxAllowedPaymentAmount: MaxAllowedPaymentAmount,
  // fiscal code of the organization, used to receive payments
  organizationFiscalCode: OrganizationFiscalCode,
  // the name of the organization
  organizationName: NonEmptyString,
  // this equals user's subscriptionId
  serviceId: NonEmptyString,
  // the name of the service
github teamdigitale / io-functions / lib / models / profile.ts View on Github external
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { BlockedInboxOrChannel } from "../api/definitions/BlockedInboxOrChannel";
import { EmailAddress } from "../api/definitions/EmailAddress";
import { FiscalCode } from "../api/definitions/FiscalCode";
import { IsInboxEnabled } from "../api/definitions/IsInboxEnabled";
import { IsWebhookEnabled } from "../api/definitions/IsWebhookEnabled";
import { PreferredLanguages } from "../api/definitions/PreferredLanguages";
import { ServiceId } from "../api/definitions/ServiceId";
import { fiscalCodeToModelId } from "../utils/conversions";

export const PROFILE_COLLECTION_NAME = "profiles";
export const PROFILE_MODEL_PK_FIELD = "fiscalCode";

const ProfileBlockedInboxOrChannels = t.dictionary(
  ServiceId,
  readonlySetType(BlockedInboxOrChannel, "ProfileBlockedInboxOrChannel"),
  "ProfileBlockedInboxOrChannels"
);

// typescript does not allow to have ServiceId as key type here
export interface IProfileBlockedInboxOrChannels {
  readonly [serviceId: string]: ReadonlySet;
}

/**
 * Base interface for Profile objects
 */
export const Profile = t.intersection([
  t.interface({
    // the fiscal code of the citized associated to this profile
    fiscalCode: FiscalCode
  }),