|
|
|
@ -28,6 +28,8 @@ export const MetaFields = { |
|
|
|
version: 'meta.version' |
|
|
|
}; |
|
|
|
|
|
|
|
export type SchemaType = 'Default' | 'Singleton'; |
|
|
|
|
|
|
|
export class SchemaDto { |
|
|
|
public readonly _links: ResourceLinks; |
|
|
|
|
|
|
|
@ -50,18 +52,32 @@ export class SchemaDto { |
|
|
|
|
|
|
|
public readonly displayName: string; |
|
|
|
|
|
|
|
public readonly contentFields: ReadonlyArray<RootFieldDto>; |
|
|
|
|
|
|
|
public readonly defaultListFields: ReadonlyArray<TableField>; |
|
|
|
public readonly defaultReferenceFields: ReadonlyArray<TableField>; |
|
|
|
|
|
|
|
public readonly isSingleton: boolean; |
|
|
|
public readonly isDefault: boolean; |
|
|
|
|
|
|
|
constructor(links: ResourceLinks, |
|
|
|
public readonly id: string, |
|
|
|
public readonly name: string, |
|
|
|
public readonly category: string, |
|
|
|
public readonly properties: SchemaPropertiesDto, |
|
|
|
public readonly isSingleton: boolean, |
|
|
|
public readonly isPublished: boolean, |
|
|
|
public readonly created: DateTime, |
|
|
|
public readonly createdBy: string, |
|
|
|
public readonly lastModified: DateTime, |
|
|
|
public readonly lastModifiedBy: string, |
|
|
|
public readonly version: Version |
|
|
|
public readonly version: Version, |
|
|
|
public readonly name: string, |
|
|
|
public readonly category: string, |
|
|
|
public readonly type: SchemaType, |
|
|
|
public readonly isPublished: boolean, |
|
|
|
public readonly properties: SchemaPropertiesDto, |
|
|
|
public readonly fields: ReadonlyArray<RootFieldDto> = [], |
|
|
|
public readonly fieldsInLists: Tags = [], |
|
|
|
public readonly fieldsInReferences: Tags = [], |
|
|
|
public readonly fieldRules: ReadonlyArray<FieldRule> = [], |
|
|
|
public readonly previewUrls = {}, |
|
|
|
public readonly scripts = {} |
|
|
|
) { |
|
|
|
this._links = links; |
|
|
|
|
|
|
|
@ -83,32 +99,9 @@ export class SchemaDto { |
|
|
|
this.canUpdateRules = hasAnyLink(links, 'update/rules'); |
|
|
|
|
|
|
|
this.displayName = StringHelper.firstNonEmpty(this.properties.label, this.name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export class SchemaDetailsDto extends SchemaDto { |
|
|
|
public readonly contentFields: ReadonlyArray<RootFieldDto>; |
|
|
|
|
|
|
|
public readonly defaultListFields: ReadonlyArray<TableField>; |
|
|
|
public readonly defaultReferenceFields: ReadonlyArray<TableField>; |
|
|
|
|
|
|
|
constructor(links: ResourceLinks, id: string, name: string, category: string, |
|
|
|
properties: SchemaPropertiesDto, |
|
|
|
isSingleton: boolean, |
|
|
|
isPublished: boolean, |
|
|
|
created: DateTime, |
|
|
|
createdBy: string, |
|
|
|
lastModified: DateTime, |
|
|
|
lastModifiedBy: string, |
|
|
|
version: Version, |
|
|
|
public readonly fields: ReadonlyArray<RootFieldDto> = [], |
|
|
|
public readonly fieldsInLists: Tags = [], |
|
|
|
public readonly fieldsInReferences: Tags = [], |
|
|
|
public readonly fieldRules: ReadonlyArray<FieldRule> = [], |
|
|
|
public readonly scripts = {}, |
|
|
|
public readonly previewUrls = {} |
|
|
|
) { |
|
|
|
super(links, id, name, category, properties, isSingleton, isPublished, created, createdBy, lastModified, lastModifiedBy, version); |
|
|
|
this.isDefault = type === 'Default'; |
|
|
|
this.isSingleton = type === 'Singleton'; |
|
|
|
|
|
|
|
if (fields) { |
|
|
|
this.contentFields = fields.filter(x => x.properties.isContentField); |
|
|
|
@ -193,7 +186,7 @@ export class SchemaDetailsDto extends SchemaDto { |
|
|
|
|
|
|
|
return copy; |
|
|
|
}), |
|
|
|
isPublished: this.isPublished |
|
|
|
type: this.type |
|
|
|
}; |
|
|
|
|
|
|
|
return result; |
|
|
|
@ -337,7 +330,7 @@ export type UpdateUIFields = |
|
|
|
Readonly<{ fieldsInLists?: Tags; fieldsInReferences?: Tags; }>; |
|
|
|
|
|
|
|
export type CreateSchemaDto = |
|
|
|
Readonly<{ name: string; fields?: ReadonlyArray<RootFieldDto>; category?: string; isSingleton?: boolean; isPublished?: boolean; properties?: SchemaPropertiesDto; }>; |
|
|
|
Readonly<{ name: string; fields?: ReadonlyArray<RootFieldDto>; category?: string; type?: string; isPublished?: boolean; properties?: SchemaPropertiesDto; }>; |
|
|
|
|
|
|
|
export type UpdateSchemaCategoryDto = |
|
|
|
Readonly<{ name?: string; }>; |
|
|
|
@ -370,22 +363,22 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.loadFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public getSchema(appName: string, name: string): Observable<SchemaDetailsDto> { |
|
|
|
public getSchema(appName: string, name: string): Observable<SchemaDto> { |
|
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/schemas/${name}`); |
|
|
|
|
|
|
|
return HTTP.getVersioned(this.http, url).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
pretifyError('i18n:schemas.loadSchemaFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public postSchema(appName: string, dto: CreateSchemaDto): Observable<SchemaDetailsDto> { |
|
|
|
public postSchema(appName: string, dto: CreateSchemaDto): Observable<SchemaDto> { |
|
|
|
const url = this.apiUrl.buildUrl(`api/apps/${appName}/schemas`); |
|
|
|
|
|
|
|
return HTTP.postVersioned(this.http, url, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'Created', appName); |
|
|
|
@ -393,14 +386,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.createFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putScripts(appName: string, resource: Resource, dto: {}, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putScripts(appName: string, resource: Resource, dto: {}, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update/scripts']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'ScriptsConfigured', appName); |
|
|
|
@ -408,14 +401,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updateScriptsFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putFieldRules(appName: string, resource: Resource, dto: ReadonlyArray<FieldRule>, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putFieldRules(appName: string, resource: Resource, dto: ReadonlyArray<FieldRule>, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update/rules']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, { fieldRules: dto }).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'RulesConfigured', appName); |
|
|
|
@ -423,14 +416,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updateRulesFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putSchemaSync(appName: string, resource: Resource, dto: SynchronizeSchemaDto, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putSchemaSync(appName: string, resource: Resource, dto: SynchronizeSchemaDto, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update/sync']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'Updated', appName); |
|
|
|
@ -438,14 +431,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.synchronizeFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putSchema(appName: string, resource: Resource, dto: UpdateSchemaDto, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putSchema(appName: string, resource: Resource, dto: UpdateSchemaDto, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'Updated', appName); |
|
|
|
@ -453,14 +446,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updateFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putCategory(appName: string, resource: Resource, dto: UpdateSchemaCategoryDto, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putCategory(appName: string, resource: Resource, dto: UpdateSchemaCategoryDto, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update/category']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'CategoryChanged', appName); |
|
|
|
@ -468,14 +461,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.changeCategoryFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putPreviewUrls(appName: string, resource: Resource, dto: {}, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putPreviewUrls(appName: string, resource: Resource, dto: {}, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update/urls']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'PreviewUrlsConfigured', appName); |
|
|
|
@ -483,14 +476,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updatePreviewUrlsFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public publishSchema(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public publishSchema(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['publish']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'Published', appName); |
|
|
|
@ -498,14 +491,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.publishFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public unpublishSchema(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public unpublishSchema(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['unpublish']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'Unpublished', appName); |
|
|
|
@ -513,14 +506,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.unpublishFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public postField(appName: string, resource: Resource, dto: AddFieldDto, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public postField(appName: string, resource: Resource, dto: AddFieldDto, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['fields/add']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldCreated', appName); |
|
|
|
@ -528,14 +521,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.addFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putUIFields(appName: string, resource: Resource, dto: UpdateUIFields, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putUIFields(appName: string, resource: Resource, dto: UpdateUIFields, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['fields/ui']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'UIFieldsConfigured', appName); |
|
|
|
@ -543,14 +536,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updateUIFieldsFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putFieldOrdering(appName: string, resource: Resource, dto: ReadonlyArray<number>, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putFieldOrdering(appName: string, resource: Resource, dto: ReadonlyArray<number>, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['fields/order']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, { fieldIds: dto }).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldsReordered', appName); |
|
|
|
@ -558,14 +551,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.reorderFieldsFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public putField(appName: string, resource: Resource, dto: UpdateFieldDto, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public putField(appName: string, resource: Resource, dto: UpdateFieldDto, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['update']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldUpdated', appName); |
|
|
|
@ -573,14 +566,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.updateFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public lockField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public lockField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['lock']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldLocked', appName); |
|
|
|
@ -588,14 +581,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.lockFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public enableField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public enableField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['enable']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldEnabled', appName); |
|
|
|
@ -603,14 +596,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.enableFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public disableField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public disableField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['disable']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldDisabled', appName); |
|
|
|
@ -618,14 +611,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.disableFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public showField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public showField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['show']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldShown', appName); |
|
|
|
@ -633,14 +626,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.showFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public hideField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public hideField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['hide']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldHidden', appName); |
|
|
|
@ -648,14 +641,14 @@ export class SchemasService { |
|
|
|
pretifyError('i18n:schemas.hideFieldFailed')); |
|
|
|
} |
|
|
|
|
|
|
|
public deleteField(appName: string, resource: Resource, version: Version): Observable<SchemaDetailsDto> { |
|
|
|
public deleteField(appName: string, resource: Resource, version: Version): Observable<SchemaDto> { |
|
|
|
const link = resource._links['delete']; |
|
|
|
|
|
|
|
const url = this.apiUrl.buildUrl(link.href); |
|
|
|
|
|
|
|
return HTTP.requestVersioned(this.http, link.method, url, version, {}).pipe( |
|
|
|
map(({ payload }) => { |
|
|
|
return parseSchemaWithDetails(payload.body); |
|
|
|
return parseSchema(payload.body); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.analytics.trackEvent('Schema', 'FieldDeleted', appName); |
|
|
|
@ -685,42 +678,32 @@ export class SchemasService { |
|
|
|
function parseSchemas(response: any) { |
|
|
|
const raw: any[] = response.items; |
|
|
|
|
|
|
|
const items = raw.map(item => |
|
|
|
new SchemaDto(item._links, |
|
|
|
item.id, |
|
|
|
item.name, |
|
|
|
item.category, |
|
|
|
parseProperties(item.properties), |
|
|
|
item.isSingleton, |
|
|
|
item.isPublished, |
|
|
|
DateTime.parseISO(item.created), item.createdBy, |
|
|
|
DateTime.parseISO(item.lastModified), item.lastModifiedBy, |
|
|
|
new Version(item.version.toString()))); |
|
|
|
const items = raw.map(parseSchema); |
|
|
|
|
|
|
|
const _links = response._links; |
|
|
|
|
|
|
|
return { items, _links, canCreate: hasAnyLink(_links, 'create') }; |
|
|
|
} |
|
|
|
|
|
|
|
function parseSchemaWithDetails(response: any) { |
|
|
|
function parseSchema(response: any) { |
|
|
|
const fields = response.fields.map(parseField); |
|
|
|
|
|
|
|
return new SchemaDetailsDto(response._links, |
|
|
|
return new SchemaDto(response._links, |
|
|
|
response.id, |
|
|
|
response.name, |
|
|
|
response.category, |
|
|
|
parseProperties(response.properties), |
|
|
|
response.isSingleton, |
|
|
|
response.isPublished, |
|
|
|
DateTime.parseISO(response.created), response.createdBy, |
|
|
|
DateTime.parseISO(response.lastModified), response.lastModifiedBy, |
|
|
|
new Version(response.version.toString()), |
|
|
|
response.name, |
|
|
|
response.category, |
|
|
|
response.type, |
|
|
|
response.isPublished, |
|
|
|
parseProperties(response.properties), |
|
|
|
fields, |
|
|
|
response.fieldsInLists, |
|
|
|
response.fieldsInReferences, |
|
|
|
response.fieldRules, |
|
|
|
response.scripts || {}, |
|
|
|
response.previewUrls || {}); |
|
|
|
response.previewUrls || {}, |
|
|
|
response.scripts || {}); |
|
|
|
} |
|
|
|
|
|
|
|
function parseProperties(response: any) { |
|
|
|
|