1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 1x 1x 1x 734x 36x 698x 1x 727x 727x 727x 727x 727x 727x 727x 727x 727x 727x 727x 727x | /** * @module Config *//** */ import { Content } from '../Content'; import { ODataFieldParameter, ODataMetadataType } from '../ODataApi/ODataParams'; import { SnConfigBehavior } from './snconfigbehavior'; import { SnConfigField } from './snconfigfielddecorator'; /** * Class that represents a typed model for the Sense/Net related configuration for an NPM Package. The values can be populated from sn.config.js. */ export class SnConfigModel { /** * The default base URL, returns window.location if available */ public static get DEFAULT_BASE_URL(): string { if (typeof window !== 'undefined') { return (window && window.location && window.location.origin) || ''; } return ''; } /** * The default Sense/Net OData Service token (odata.svc) */ public static readonly DEFAULT_SERVICE_TOKEN: string = 'odata.svc'; /** * The root URL for the Sense/Net repository (e.g.: demo.sensenet.com) */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig | SnConfigBehavior.AllowFromCommandLine, FieldDescription: 'URL to the repository (e.g.: demo.sensenet.com)', Question: 'Please enter your Sense/Net Site URL(e.g.:demo.sensenet.com):', }) public RepositoryUrl: string = SnConfigModel.DEFAULT_BASE_URL; /** * The service token for the OData Endpoint */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig | SnConfigBehavior.AllowFromCommandLine, FieldDescription: 'The service token for the OData Endpoint', Question: 'Please enter your Sense/Net Site URL(e.g.:demo.sensenet.com):', }) // tslint:disable-next-line:naming-convention public ODataToken: string = SnConfigModel.DEFAULT_SERVICE_TOKEN; /** * This string represents how the Jwt Web Token will be stored in the localStorage. */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'Template will be stored in that format', Question: 'Please specify the template format for the key of the JWT Web Token in the localStorage (e.g.: sn-${siteName}-${tokenName})' }) public JwtTokenKeyTemplate: string = 'sn-${siteName}-${tokenName}'; /** * This string describes how long the JWT token should be persisted. */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The behavoir how long the JWT tokens should be persisted, can be "session" or "expiration"', Question: '' }) public JwtTokenPersist: 'session' | 'expiration' = 'session'; /** * This parameter describes what fields should be included in the OData $select statements by default */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The default values to select when triggering an OData Action', Question: '' }) public DefaultSelect: ODataFieldParameter<Content> | 'all' = ['DisplayName', 'Description', 'Icon']; /** * This parameter describes what fields should always be included in the OData $select statements */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The values are required when triggering an OData Action and will be always included in Select statements', Question: '' }) public RequiredSelect: ODataFieldParameter<Content> = ['Id', 'Path', 'Name', 'Type']; /** * This field sets the default OData $metadata value */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The default OData metadata option', Question: '' }) public DefaultMetadata: ODataMetadataType = 'no'; /** * This field sets the default OData inline count value */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The default OData inline count option', Question: '' }) public DefaultInlineCount: 'allpages' | 'none' = 'allpages'; /** * This field describes what fields should be expanded on every OData request by default */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The default OData references to expand', Question: '' }) public DefaultExpand: ODataFieldParameter<Content> | undefined = undefined; /** * This field sets up a default OData $top parameter */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'The default OData $top parameter for querying / fetching content', Question: '' }) public DefaultTop: number = 1000; /** * Chunk size for chunked uploads, must be equal to BinaryChunkSize setting at the backend */ @SnConfigField({ Behavior: SnConfigBehavior.AllowFromConfig, FieldDescription: 'Chunk size for chunked uploads, must be equal to BinaryChunkSize setting at the backend', Question: '' }) public ChunkSize: number = 10485760; // 10 mb /** * * @param {Partial<SnConfigMoel>} config Partial config values, the default values will be overwritten if provided * @constructs {SnConfigModel} */ constructor(config?: Partial<SnConfigModel>) { config && Object.assign(this, config); } } |