Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
ng-model-generator-bundle
Commits
884c6a70
Commit
884c6a70
authored
Dec 03, 2018
by
Guillaume Perréal
Browse files
Si les paramètres d'une IRI sont constitués d'une chaîne toute seule, ne demande pas de tableau.
parent
d817b5f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Resources/views/_macros.ts.twig
0 → 100644
View file @
884c6a70
{%
macro
iriParameterType
(
repo
)
-
%}
{%
-
autoescape
false
-
%}
{%
-
if
repo.iri.parameters
is
empty
-
%}
void
{%
-
elseif
repo.iri.parameters
|
length
==
1
-
%}
{%
-
for
param
in
repo.iri.parameters
-
%}
{{
-
param.type.usage
}}
{%
-
endfor
-
%}
{%
-
else
-
%}
[
{%
for
param
in
repo.iri.parameters
-
%}
{{
-
param.type.usage
}}{%
if
not
loop.last
%}
,
{%
endif
-
%}
{%
-
endfor
%}
]
{%
-
endif
-
%}
{%
-
endautoescape
-
%}
{%
-
endmacro
%}
{%
macro
metadataType
(
repo
)
-
%}
{%
-
autoescape
false
-
%}
{%
-
import
_self
as
m
-
%}
ResourceMetadata
<
{{
repo.resourceName
}}
,
{{
repo.resourceName
|
quoteString
}}
,
{{
m.iriParameterType
(
repo
)
}}
>
{%
-
endautoescape
-
%}
{%
-
endmacro
%}
src/Resources/views/common.ts.twig
View file @
884c6a70
...
...
@@ -140,12 +140,17 @@ export abstract class AbstractResourceCache {
public abstract invalidate
<R
extends
Resource
>
(iri: IRI
<R>
): void;
}
/**
* Type des paramètrès
*/
export type IRIParameters = string[] | string;
/**
* Informations sur l'IRI d'une resource.
*
* P: types des paramètres.
*/
export class IRIMetadata
<P
extends
string
[]
>
{
export class IRIMetadata
<P
extends
IRIParameters
>
{
public constructor(
private readonly testPattern: RegExp,
private readonly capturePattern: RegExp,
...
...
@@ -182,7 +187,7 @@ function getResourceType(that: any): string | null {
* R : type de resource, e.g. Person
* T : valeur de la propriété '@type', e.g. 'Person'.
*/
export class ResourceMetadata
<R
extends
Resource
,
T
extends
string
,
P
extends
string[] =
[UUID]
>
{
export class ResourceMetadata
<R
extends
Resource
,
T
extends
string
,
P
extends
IRIParameters
>
{
public constructor(
public readonly type: T,
public readonly iri: IRIMetadata
<P>
,
...
...
@@ -221,7 +226,7 @@ export class ResourceMetadata<R extends Resource, T extends string, P extends st
/**
* Classe de base d'un repository.
*/
export abstract class AbstractRepository
<R
extends
Resource
,
T
extends
string
,
P
extends
string[] =
[UUID]
>
{
export abstract class AbstractRepository
<R
extends
Resource
,
T
extends
string
,
P
extends
IRIParameters
>
{
public constructor(
public readonly metadata: ResourceMetadata
<R
,
T
,
P
>
,
protected readonly client: HttpClient,
...
...
@@ -242,9 +247,9 @@ export abstract class AbstractRepository<R extends Resource, T extends string, P
export interface APIMeta {
[type: string]: {
resource: Resource;
metadata: ResourceMetadata
<any
,
any
,
any
>
;
repository: AbstractRepository
<any
,
any
,
any
>
;
iriParameters:
string[]
;
metadata: ResourceMetadata
<any
,
any
,
IRIParameters
>
;
repository: AbstractRepository
<any
,
any
,
IRIParameters
>
;
iriParameters:
IRIParameters
;
};
}
...
...
src/Resources/views/metadata.ts.twig
View file @
884c6a70
{%
extends
'@NgModelGenerator/_layout.ts.twig'
%}
{%
macro
iriParameterType
(
repo
)
-
%}
{%
-
autoescape
false
-
%}
[
{%
for
param
in
repo.iri.parameters
-
%}
{{
-
param.type.usage
}}{%
if
not
loop.last
%}
,
{%
endif
-
%}
{%
-
endfor
%}
]
{%
-
endautoescape
-
%}
{%
-
endmacro
%}
{%
macro
metadataType
(
repo
)
-
%}
{%
-
autoescape
false
-
%}
{%
-
import
_self
as
m
-
%}
ResourceMetadata
<
{{
repo.resourceName
}}
,
{{
repo.resourceName
|
quoteString
}}
,
{{
m.iriParameterType
(
repo
)
}}
>
{%
-
endautoescape
-
%}
{%
-
endmacro
%}
{%
import
_self
as
m
%}
{%
import
'@NgModelGenerator/_macros.ts.twig'
as
m
%}
{%
block
content
%}
{%
autoescape
false
%}
...
...
@@ -75,11 +60,13 @@ export class AppMetadata extends LazyMetadataRegistry<AppAPI> {
new IRIMetadata(
/^
{{
repo.iri.testPattern
}}
$/u,
/^
{{
repo.iri.capturePattern
}}
$/u,
([
{%
-
for
param
in
repo.iri.parameters
-
%}
(
{%
-
if
repo.iri.parameters
|
length
>
1
%}
[
{%
endif
-
%}
{%
-
for
param
in
repo.iri.parameters
-
%}
{{
param.name
}}{%
if
not
loop.last
%}
,
{%
endif
-
%}
{%
-
endfor
-
%}
]:
{{
m.iriParameterType
(
repo
)
}}
) =>
{{
repo.iri.usage
}}
{%
-
if
repo.iri.parameters
|
length
>
1
%}
]
{%
endif
-
%}
:
{{
m.iriParameterType
(
repo
)
}}
) =>
{{
repo.iri.usage
}}
),
[
{%
if
repo.resource.properties
is
defined
-
%}
{%
-
for
name
,
property
in
repo.resource.properties
if
not
property.nullable
%}{{
property.name
|
quoteString
}}
,
{%
endfor
-
%}
...
...
src/Resources/views/repositories.ts.twig
View file @
884c6a70
{%
extends
'@NgModelGenerator/_layout.ts.twig'
%}
{%
import
'@NgModelGenerator/_macros.ts.twig'
as
m
%}
{%
block
content
%}
{%
autoescape
false
%}
import { Observable } from 'rxjs';
...
...
@@ -15,7 +17,7 @@ import { {% for name in repoImports %}
* Repositories
*********************************************************************************/
{%
for
repo
in
repositories
%}
export class
{{
repo.name
}}
extends AbstractRepository
<
{{
repo.resource.usage
}}
,
{{
repo.resourceName
|
quoteString
}}
>
{
export class
{{
repo.name
}}
extends AbstractRepository
<
{{
repo.resource.usage
}}
,
{{
repo.resourceName
|
quoteString
}}
,
{{
m.iriParameterType
(
repo
)
}}
>
{
{%
for
op
in
repo.operations
%}
{%
if
op.description
-
%}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment