Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit b7b5fb2

Browse files
committed
Migrate from eMundo GitLab to GitHub
0 parents  commit b7b5fb2

28 files changed

+1229
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
spec
4+
package
5+
6+
# macOS
7+
.DS_Store

.gitlab-ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Beschreibt wie unsere CI/CD Pipeline mit der Gitlab-CI funktioniert
2+
#
3+
# Referenz: https://docs.gitlab.com/ce/ci/yaml/
4+
# Linter: https://gitsc.emundo.eu/ci/lint
5+
# Doku: https://gitsc.emundo.eu/help/ci/README.md
6+
#
7+
# Authoren: Oliver Broome
8+
# Lukas Lisowski
9+
# Simon Nagl
10+
11+
# Wir brauchen genau dieses Image und kein Alpine weil sonst u.a. Karma, Jasmine
12+
# und der Webpack Build nicht ordentlich läuft
13+
image: node:latest
14+
15+
stages:
16+
- rebased
17+
- compile
18+
- package
19+
- test
20+
- publish
21+
22+
cache:
23+
key: "default"
24+
paths:
25+
- node_modules/
26+
27+
# Wird vor jeder stage ausgeführt.
28+
before_script:
29+
# Nun stellen wir nochmal sicher, dass alle npm-Pakete im Cache vorhanden sind
30+
- npm install
31+
# und löschen die überzähligen
32+
- npm prune
33+
34+
rebased:
35+
stage: rebased
36+
# Wir brauchen hier einfach nur kurz und bündig ein Git image
37+
image: docker:git
38+
only:
39+
# die Prüfung ob gerebased ist passiert nur in Branches
40+
- branches
41+
# oder durchs antriggern
42+
- triggers
43+
cache:
44+
# wir brauchen keinen Cache
45+
key: "none"
46+
before_script:
47+
# Wir brauchen die allgemeinen Skripte hier nicht
48+
- echo "check if branch is rebased on master"
49+
script:
50+
# Variable wird mit Gitlab >= 9.0 auf CI_COMMIT_REF_NAME umbenannt. TODO Lukas/Oliver
51+
- if ! git merge-base --is-ancestor origin/master origin/$CI_BUILD_REF_NAME ; then exit 1; fi
52+
53+
compile:
54+
stage: compile
55+
script:
56+
- npm run build
57+
58+
build:
59+
stage: package
60+
script:
61+
- npm run build
62+
- npm pack
63+
artifacts:
64+
when: on_success
65+
expire_in: 1 week
66+
paths:
67+
- jsog-ts-*.tgz
68+
69+
test:
70+
stage: test
71+
script:
72+
- npm run test
73+
74+
deploy-npm:
75+
stage: publish
76+
only:
77+
- manual
78+
- tags
79+
script:
80+
# Wir bauen die Anwendung für die Zielumgebung mit der Config
81+
- npm run build
82+
- echo "TODO Create .npmrc with token from secrete gitlab variable"
83+
- npm publish

.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
src
2+
spec
3+
tsconfig.test.json
4+
jasmine.json
5+
.gitlab-ci.yml
6+
tsconfig*.json
7+
tslint.json
8+
package
9+
.npmignore
10+
.vscode/

.vscode/launch.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "jasmine",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/node_modules/jasmine/bin/jasmine.js",
9+
"stopOnEntry": false,
10+
"args": [
11+
"--config=jasmine.json"
12+
],
13+
"cwd": "${workspaceRoot}",
14+
"runtimeArgs": [
15+
"--nolazy"
16+
],
17+
"env": {
18+
"NODE_ENV": "development"
19+
},
20+
"sourceMaps": true,
21+
"outFiles": [
22+
"${workspaceRoot}/**/*.js"
23+
]
24+
}
25+
]
26+
}

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 Voost LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# JavaScript Object Graphs with Typescript
2+
3+
This Typescript module implements [JSOG format](https://github.com/jsog/jsog).
4+
It is able to instantiante typescript objects during deserialization.
5+
6+
## Usage
7+
8+
### Installation
9+
10+
```
11+
npm --save jsog-ts
12+
```
13+
14+
Enable typescript `experimentalDecorator` and `emitDecoratorMetadata` compiler options.
15+
16+
Minimal tslint.json:
17+
```
18+
{
19+
"compilerOptions": {
20+
"experimentalDecorators": true,
21+
"emitDecoratorMetadata": true,
22+
}
23+
}
24+
```
25+
26+
### General
27+
28+
Generate a new instance of the service. See Integration for integration to some popular frameworks.
29+
30+
```
31+
import { jsogService } from 'jsog-ts'
32+
33+
const jsog = new JsogService();
34+
```
35+
36+
Use it to serialize and deserialize JavaScript Objects.
37+
```
38+
jsog.serialize(javaScriptObject);
39+
jsog.deserialize(jsogObjectGraph);
40+
```
41+
42+
### Instatiate Typescript Objects
43+
44+
Description how to instatiate Typescript objects to provide convinent methods and use the `typeof` operator.
45+
46+
Instantiate the root object or a list of rootObjects:
47+
```
48+
jsog.deserializeObject(jsogObjectGraph, ExampleClass);
49+
jsog.deserializeArray(jsogObjectArray, ExampleClass);
50+
```
51+
52+
To instantiate references somewhere in the tree decorate class properties to instantiate with `@JsonProperty()` and properties with Lists containing objects of type `ExamplecClass` use `@JsonProperty(ExampleClass)`.
53+
54+
### Integration
55+
56+
#### Angular 4
57+
58+
Provide JsogService as an Angular 4 Service which can be injected into your Components/Services.
59+
60+
```
61+
import { NgModule } from '@angular/core';
62+
import { JsogService } from 'jsog-ts';
63+
64+
@NgModule({
65+
providers: [
66+
JsogService
67+
]
68+
)}
69+
```
70+
71+
#### AngularJs
72+
73+
Register JsogService as an Angular Service
74+
75+
```
76+
import { module } from 'angular';
77+
import { JsogService } from 'jsog-ts';
78+
79+
module.service('JsogService', JsogService)
80+
```
81+
82+
## Developer Guide
83+
84+
### System dependencies
85+
- [npm](https://www.npmjs.com/) (4.6.1)
86+
87+
## Author
88+
89+
* Simon Nagl (simon.nagl@e-mundo.de)
90+
91+
## License
92+
93+
This software is provided under the [MIT license](http://opensource.org/licenses/MIT)
94+
95+
This software uses code and ideas from:
96+
97+
- [JSOG - JavaScript Object Graph](https://github.com/jsog/jsog)
98+
- [json-typescript-mapper](https://github.com/jf3096/json-typescript-mapper)

jasmine.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"spec_dir": "spec",
3+
"spec_files": [
4+
"**/*[sS]pec.js"
5+
],
6+
"stopSpecOnExpectationFailure": false
7+
}

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "jsog-ts",
3+
"version": "0.1.0",
4+
"description": "JavaScript Object Graphs with Typescript",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
7+
"scripts": {
8+
"prebuild": "tslint --config tslint.json --type-check --project tsconfig.json --format stylish",
9+
"build": "tsc -p tsconfig.json",
10+
"pretest": "tslint --config tslint.json --type-check --project tsconfig.test.json --format stylish && tsc -p tsconfig.test.json",
11+
"test": "jasmine --config=jasmine.json",
12+
"prepare": "npm run build"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/e-mundo/jsog-ts.git"
17+
},
18+
"keywords": [
19+
"typescript",
20+
"jsog",
21+
"npm"
22+
],
23+
"contributors": [
24+
"Simon Nagl <simon.nagl@e-mundo.de>"
25+
],
26+
"author": "eMundo GmbH",
27+
"license": "MIT",
28+
"dependencies": {
29+
"reflect-metadata": "^0.1.10"
30+
},
31+
"devDependencies": {
32+
"@types/jasmine": "^2.5.51",
33+
"jasmine": "^2.6.0",
34+
"jasmine-spec-reporter": "^4.1.1",
35+
"moment": "^2.18.1",
36+
"tslint": "^5.4.3",
37+
"tslint-microsoft-contrib": "^5.0.0",
38+
"tsutils": "=1.6.0",
39+
"typescript": "^2.3.4"
40+
},
41+
"false": {}
42+
}

package.json.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# package.json Documentation
2+
3+
This is the documentation of `package.json`.
4+
This is required because `package.json` is JSON and which does not support comments.
5+
6+
## devDependencies
7+
8+
- tsutils@1.6.0 is required by tslint-microsoft-contrib@5.0.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Class } from '../support/Class';
2+
import 'reflect-metadata';
3+
4+
/**
5+
* Marks an property for Class instantiation.
6+
*
7+
* If the property is an Array clazz must be supplied with the clazz of the Array elements.
8+
*
9+
* @param clazz Class to instantiate elements.
10+
*/
11+
export function JsonProperty<T extends object>(clazz?: Class<T>): PropertyDecorator {
12+
return Reflect.metadata('JsonProperty', clazz);
13+
}

0 commit comments

Comments
 (0)