Skip to content

Commit ec2d649

Browse files
committed
Use enum and union types for better field type definitions.
1 parent 86c4910 commit ec2d649

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"name": "angular-point",
33
"description": "A library designed to allow Angular2 to work with SharePoint's SOAP API's.",
4-
"authors": ["Scott <[email protected]>"],
4+
"authors": [
5+
6+
],
57
"homepage": "https://github.com/scatcher/angular-point",
6-
"version": "6.2.0",
8+
"version": "6.3.0",
79
"license": "MIT",
810
"angular-cli": {},
911
"scripts": {

src/angular-point.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import * as angular from 'angular';
2-
32
import { DefaultFields } from './constants/apDefaultFields';
43
import { DefaultListItemQueryOptions } from './constants/apDefaultListItemQueryOptions';
54
import { BasePermissionObject, UserPermissionsObject } from './constants/apPermissionObject';
65
import { WebServiceOperationConstants } from './constants/apWebServiceOperationConstants';
76
import { XMLFieldAttributeTypes } from './constants/apXMLFieldAttributeTypes';
87
import { XMLListAttributeTypes } from './constants/apXMLListAttributeTypes';
98
import { CamlFactory } from './factories/apCamlFactory';
10-
import { FieldFactory, FieldConfigurationObject, FieldDefinition } from './factories/apFieldFactory';
11-
import { IndexedCacheFactory, IndexedCache } from './factories/apIndexedCacheFactory';
12-
import { ListItemFactory, ListItem } from './factories/apListItemFactory';
13-
import { ModelFactory, Model, QueriesContainer } from './factories/apModelFactory';
9+
import { FieldConfigurationObject, FieldDefinition, FieldFactory } from './factories/apFieldFactory';
10+
import { IndexedCache, IndexedCacheFactory } from './factories/apIndexedCacheFactory';
11+
import { List } from './factories/apListFactory';
12+
import { ListItem, ListItemFactory } from './factories/apListItemFactory';
1413
import {
15-
ListItemVersionFactory,
1614
ChangeSummary,
17-
VersionSummary,
1815
ListItemVersion,
16+
ListItemVersionFactory,
17+
VersionSummary,
1918
} from './factories/apListItemVersionFactory';
20-
import { LookupFactory, Lookup } from './factories/apLookupFactory';
21-
import { QueryFactory, Query } from './factories/apQueryFactory';
22-
import { UserFactory, User } from './factories/apUserFactory';
19+
import { Lookup, LookupFactory } from './factories/apLookupFactory';
20+
import { Model, ModelFactory, QueriesContainer } from './factories/apModelFactory';
21+
import { Query, QueryFactory } from './factories/apQueryFactory';
22+
import { User, UserFactory } from './factories/apUserFactory';
23+
import { FieldTypeEnum, FieldTypeUnion, XMLFieldDefinition, XMLGroup, XMLList, XMLUser } from './interfaces';
2324
import { UserModel } from './models/apUserModel';
2425
import { CacheService } from './services/apCacheService';
2526
import { ChangeService } from './services/apChangeService';
@@ -30,14 +31,12 @@ import { exceptionLoggingService } from './services/apExceptionHandlerService';
3031
import { ExportService } from './services/apExportService';
3132
import { FieldService } from './services/apFieldService';
3233
import { FormattedFieldValueService } from './services/apFormattedFieldValueService';
34+
import { LogEvent, Logger } from './services/apLogger';
35+
import { LookupCacheService } from './services/apLookupCacheService';
3336
import { SPServicesCore } from './services/apSPServices';
34-
import { Logger, LogEvent } from './services/apLogger';
3537
import { UtilityService } from './services/apUtilityService';
3638
import { WebServiceService } from './services/apWebServiceService';
3739
import { XMLToJSONService } from './services/apXMLToJSONService';
38-
import { List, ListFieldMapping } from './factories/apListFactory';
39-
import { LookupCacheService } from './services/apLookupCacheService';
40-
import { FieldTypeEnum, XMLUser, XMLGroup, XMLFieldDefinition, XMLList } from './interfaces';
4140

4241
export let $AP_INJECTOR: ng.auto.IInjectorService;
4342

@@ -111,6 +110,7 @@ export {
111110
FieldConfigurationObject,
112111
FieldDefinition,
113112
FieldTypeEnum,
113+
FieldTypeUnion,
114114
IndexedCache,
115115
IndexedCacheFactory,
116116
List,

src/factories/apFieldFactory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as _ from 'lodash';
2+
import { FieldTypeEnum, FieldTypeUnion, XMLFieldDefinition } from '../interfaces';
23
import { FieldService } from '../services/apFieldService';
3-
import { UtilityService } from '../services/apUtilityService';
44
import { FormattedFieldValueService } from '../services/apFormattedFieldValueService';
5+
import { UtilityService } from '../services/apUtilityService';
56
import { ListItem } from './apListItemFactory';
6-
import { XMLFieldDefinition, FieldTypeEnum } from '../interfaces';
77

88
let apFieldService: FieldService,
99
apUtilityService: UtilityService,
@@ -17,7 +17,7 @@ export interface FieldConfigurationObject {
1717
label?: string;
1818
// JS property name that we use to store the value for this field.
1919
mappedName: string;
20-
objectType: FieldTypeEnum;
20+
objectType: FieldTypeUnion;
2121
readOnly?: boolean;
2222
required?: boolean;
2323
staticName: string;

src/interfaces/field-types.enum.ts

+23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum FieldTypeEnum {
2+
Attachments = 'Attachments',
23
Boolean = 'Boolean',
34
Calculated = 'Calculated',
45
Choice = 'Choice',
@@ -21,3 +22,25 @@ export enum FieldTypeEnum {
2122
Integer = 'Integer',
2223
Float = 'Float',
2324
}
25+
26+
export type FieldTypeUnion =
27+
| FieldTypeEnum.Attachments
28+
| FieldTypeEnum.Boolean
29+
| FieldTypeEnum.Calculated
30+
| FieldTypeEnum.Choice
31+
| FieldTypeEnum.Counter
32+
| FieldTypeEnum.Currency
33+
| FieldTypeEnum.DateTime
34+
| FieldTypeEnum.Lookup
35+
| FieldTypeEnum.LookupMulti
36+
| FieldTypeEnum.Mask
37+
| FieldTypeEnum.MultiChoice
38+
| FieldTypeEnum.Note
39+
| FieldTypeEnum.Number
40+
| FieldTypeEnum.Text
41+
| FieldTypeEnum.User
42+
| FieldTypeEnum.UserMulti
43+
| FieldTypeEnum.JSON
44+
| FieldTypeEnum.HTML
45+
| FieldTypeEnum.Integer
46+
| FieldTypeEnum.Float;

0 commit comments

Comments
 (0)