@rentman/rm-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.editorconfig +23 -0
  2. package/package.json +33 -0
  3. package/src/classes/ApiFormatter.ts +338 -0
  4. package/src/classes/BatchStatus.ts +86 -0
  5. package/src/classes/ChangesCompiler.ts +161 -0
  6. package/src/classes/ChangesProcessor.ts +475 -0
  7. package/src/classes/CollectionCache.ts +234 -0
  8. package/src/classes/CollectionEntryService.ts +83 -0
  9. package/src/classes/CollectionHandler.ts +619 -0
  10. package/src/classes/CollectionResourceService.ts +38 -0
  11. package/src/classes/ColumnCache.ts +114 -0
  12. package/src/classes/ColumnExpansion.ts +74 -0
  13. package/src/classes/ColumnHandler.ts +90 -0
  14. package/src/classes/ColumnSet.ts +181 -0
  15. package/src/classes/ColumnUtil.ts +589 -0
  16. package/src/classes/CreateRequest.ts +158 -0
  17. package/src/classes/ItemAdministrator.ts +571 -0
  18. package/src/classes/ItemCache.ts +158 -0
  19. package/src/classes/ItemEntryService.ts +488 -0
  20. package/src/classes/ItemHandler.ts +592 -0
  21. package/src/classes/ItemRequestService.ts +229 -0
  22. package/src/classes/ItemResourceService.ts +36 -0
  23. package/src/classes/KeyService.ts +76 -0
  24. package/src/classes/LockService.ts +184 -0
  25. package/src/classes/ModuleChangesCompiler.ts +123 -0
  26. package/src/classes/PromiseService.ts +19 -0
  27. package/src/classes/QueryMatcher.ts +135 -0
  28. package/src/classes/QueryParser.ts +209 -0
  29. package/src/classes/QueryService.ts +35 -0
  30. package/src/classes/RequestColumnExpansion.ts +31 -0
  31. package/src/classes/ResourceCache.ts +289 -0
  32. package/src/classes/Util.ts +422 -0
  33. package/src/constants.ts +11 -0
  34. package/src/factories/BatchStatusFactory.ts +18 -0
  35. package/src/factories/ChangesCompilerFactory.ts +20 -0
  36. package/src/factories/ChangesProcessorFactory.ts +53 -0
  37. package/src/factories/CollectionCacheFactory.ts +15 -0
  38. package/src/factories/CollectionEntryFactory.ts +35 -0
  39. package/src/factories/CollectionResourceFactory.ts +36 -0
  40. package/src/factories/ColumnExpansionFactory.ts +25 -0
  41. package/src/factories/ColumnSetFactory.ts +24 -0
  42. package/src/factories/CreateRequestFactory.ts +28 -0
  43. package/src/factories/ItemCacheFactory.ts +18 -0
  44. package/src/factories/ItemEntryFactory.ts +18 -0
  45. package/src/factories/ItemResourceFactory.ts +28 -0
  46. package/src/factories/ModuleChangesCompilerFactory.ts +21 -0
  47. package/src/factories/QueryMatcherFactory.ts +20 -0
  48. package/src/factories/QueryParserFactory.ts +10 -0
  49. package/src/factories/RequestColumnExpansionFactory.ts +15 -0
  50. package/src/factories/ResourceCacheFactory.ts +55 -0
  51. package/src/index.ts +188 -0
  52. package/src/interfaces/ApiRequestServiceInterface.ts +17 -0
  53. package/src/interfaces/AuthInterface.ts +5 -0
  54. package/src/interfaces/ErrorHandlerInterface.ts +3 -0
  55. package/src/interfaces/ResourceCacheInterface.ts +9 -0
  56. package/src/models/CollectionEditResource.ts +139 -0
  57. package/src/models/CollectionEntry.ts +448 -0
  58. package/src/models/CollectionResource.ts +223 -0
  59. package/src/models/CollectionViewResource.ts +23 -0
  60. package/src/models/EditResource.ts +15 -0
  61. package/src/models/ItemEntry.ts +24 -0
  62. package/src/models/ItemResource.ts +35 -0
  63. package/src/models/ViewResource.ts +14 -0
  64. package/tsconfig.json +12 -0
  65. package/tslint.json +63 -0
  66. package/webpack.common.js +35 -0
  67. package/webpack.dev.js +10 -0
  68. package/webpack.prod.js +17 -0
@@ -0,0 +1,24 @@
1
+ import ItemResource from "./ItemResource";
2
+
3
+ let currentId = 0;
4
+
5
+ export default class ItemEntry {
6
+ entryId: number;
7
+
8
+ modified;
9
+ parent: null | { itemType: string, itemId: string } = null;
10
+
11
+ deferRequest = false;
12
+ deferred;
13
+
14
+ constructor (
15
+ public itemType: string,
16
+ public itemId: number,
17
+ public columns?,
18
+ public initial = {},
19
+ public derived = {},
20
+ public resources: ItemResource[] = []
21
+ ) {
22
+ this.entryId = ++currentId;
23
+ }
24
+ }
@@ -0,0 +1,35 @@
1
+ import ItemEntryService from '../classes/ItemEntryService';
2
+ import ItemEntry from "./ItemEntry";
3
+
4
+ export default class ItemResource {
5
+ derived;
6
+ columns;
7
+ fields;
8
+
9
+ constructor (
10
+ private itemEntryService: ItemEntryService,
11
+ public entry: ItemEntry,
12
+ public options
13
+ ) {
14
+ this.derived = entry.derived;
15
+ this.columns = entry.columns.response[entry.columns.itemType];
16
+
17
+ entry.resources.push(this);
18
+ }
19
+
20
+ isLocal () {
21
+ return this.itemEntryService.isLocal(this.entry);
22
+ }
23
+
24
+ clearResource () {
25
+ const resources = this.entry.resources;
26
+ const index = resources.indexOf(this);
27
+
28
+ if (index !== -1)
29
+ resources.splice(index, 1);
30
+ }
31
+
32
+ deactivate () {
33
+ this.options.onDeactivate(this);
34
+ }
35
+ }
@@ -0,0 +1,14 @@
1
+ import ItemEntryService from '../classes/ItemEntryService';
2
+ import ItemEntry from "./ItemEntry";
3
+ import ItemResource from "./ItemResource";
4
+
5
+ export class ViewResource extends ItemResource {
6
+ fields;
7
+
8
+ constructor (itemEntryService: ItemEntryService, entry: ItemEntry, options) {
9
+ super(itemEntryService, entry, options);
10
+
11
+ this.fields = entry.modified === undefined ?
12
+ entry.initial : entry.modified;
13
+ }
14
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declarationDir": "./definitions",
4
+ "outDir": "./dist",
5
+ "noImplicitAny": false,
6
+ "declaration": true,
7
+ "module": "es6",
8
+ "target": "es5",
9
+ "sourceMap": true,
10
+ "moduleResolution": "node"
11
+ }
12
+ }
package/tslint.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "extends": "tslint:recommended",
3
+ "rules": {
4
+ "no-duplicate-variable": true,
5
+ "no-unused-variable": [
6
+ true
7
+ ],
8
+ "indent": [
9
+ true,
10
+ "tabs",
11
+ 4
12
+ ],
13
+ "no-console": [
14
+ false
15
+ ],
16
+ "variable-name": [
17
+ true,
18
+ "check-format",
19
+ "allow-leading-underscore"
20
+ ],
21
+ "trailing-comma": [
22
+ false
23
+ ],
24
+ "quotemark": [
25
+ false
26
+ ],
27
+ "member-access": [
28
+ true,
29
+ "no-public"
30
+ ],
31
+ "space-before-function-paren": true,
32
+ "rulesDirectory": [
33
+ "node_modules/tslint-eslint-rules/dist/rules"
34
+ ],
35
+ "arrow-parens": [
36
+ true,
37
+ "ban-single-arg-parens"
38
+ ],
39
+ "object-literal-shorthand": false,
40
+ "object-literal-sort-keys": false,
41
+ "ordered-imports": false,
42
+ "member-ordering": false,
43
+ "no-empty": false,
44
+ "max-line-length": [
45
+ true,
46
+ {
47
+ "limit": 160,
48
+ "ignore-pattern": "^import"
49
+ }
50
+ ],
51
+ "one-line": false,
52
+ "curly": [
53
+ false
54
+ ],
55
+ "no-string-literal": false,
56
+ "forin": false,
57
+ "no-angle-bracket-type-assertion": false,
58
+ "interface-name": [
59
+ true,
60
+ "never-prefix"
61
+ ]
62
+ }
63
+ }
@@ -0,0 +1,35 @@
1
+ const path = require('path');
2
+ const webpack = require('webpack');
3
+ const CleanWebpackPlugin = require('clean-webpack-plugin');
4
+
5
+ const pathsToClean = [
6
+ 'dist'
7
+ ];
8
+
9
+ module.exports = {
10
+ entry: './src/index.ts',
11
+ module: {
12
+ rules: [
13
+ {
14
+ test: /\.tsx?$/,
15
+ use: 'ts-loader',
16
+ exclude: /node_modules/
17
+ }
18
+ ]
19
+ },
20
+ externals: {
21
+ moment: "moment"
22
+ },
23
+ resolve: {
24
+ extensions: ['.tsx', '.ts', '.js']
25
+ },
26
+ plugins: [
27
+ new CleanWebpackPlugin(pathsToClean)
28
+ ],
29
+ output: {
30
+ filename: 'rm-core.js',
31
+ path: path.resolve(__dirname, 'dist'),
32
+ library: 'RmCore',
33
+ libraryTarget: "umd"
34
+ }
35
+ };
package/webpack.dev.js ADDED
@@ -0,0 +1,10 @@
1
+ const merge = require('webpack-merge');
2
+ const common = require('./webpack.common.js');
3
+
4
+ module.exports = merge(common, {
5
+ mode: 'development',
6
+ devtool: 'inline-source-map',
7
+ stats: {
8
+ colors: true
9
+ }
10
+ });
@@ -0,0 +1,17 @@
1
+ const webpack = require('webpack');
2
+ const merge = require('webpack-merge');
3
+ const common = require('./webpack.common.js');
4
+ const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
5
+
6
+ module.exports = merge(common, {
7
+ mode: 'production',
8
+ devtool: 'source-map',
9
+ plugins: [
10
+ new UglifyJsPlugin({
11
+ sourceMap: true
12
+ }),
13
+ new webpack.DefinePlugin({
14
+ 'process.env.NODE_ENV': JSON.stringify('production')
15
+ })
16
+ ]
17
+ });