praxis 2.0.pre.9 → 2.0.pre.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +11 -0
  4. data/TODO.md +1 -4
  5. data/bin/praxis +11 -13
  6. data/lib/praxis.rb +10 -3
  7. data/lib/praxis/action_definition.rb +15 -13
  8. data/lib/praxis/action_definition/headers_dsl_compiler.rb +0 -7
  9. data/lib/praxis/api_general_info.rb +1 -1
  10. data/lib/praxis/application.rb +6 -2
  11. data/lib/praxis/blueprint.rb +357 -0
  12. data/lib/praxis/bootloader.rb +9 -3
  13. data/lib/praxis/bootloader_stages/environment.rb +15 -13
  14. data/lib/praxis/collection.rb +1 -11
  15. data/lib/praxis/config_hash.rb +44 -0
  16. data/lib/praxis/docs/{openapi → open_api}/info_object.rb +0 -0
  17. data/lib/praxis/docs/{openapi → open_api}/media_type_object.rb +0 -0
  18. data/lib/praxis/docs/{openapi → open_api}/operation_object.rb +0 -0
  19. data/lib/praxis/docs/{openapi → open_api}/parameter_object.rb +0 -0
  20. data/lib/praxis/docs/{openapi → open_api}/paths_object.rb +0 -0
  21. data/lib/praxis/docs/{openapi → open_api}/request_body_object.rb +0 -0
  22. data/lib/praxis/docs/{openapi → open_api}/response_object.rb +0 -0
  23. data/lib/praxis/docs/{openapi → open_api}/responses_object.rb +0 -0
  24. data/lib/praxis/docs/{openapi → open_api}/schema_object.rb +0 -0
  25. data/lib/praxis/docs/{openapi → open_api}/server_object.rb +0 -0
  26. data/lib/praxis/docs/{openapi → open_api}/tag_object.rb +0 -0
  27. data/lib/praxis/docs/open_api_generator.rb +90 -5
  28. data/lib/praxis/endpoint_definition.rb +273 -0
  29. data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +1 -1
  30. data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +1 -1
  31. data/lib/praxis/extensions/field_expansion.rb +3 -36
  32. data/lib/praxis/extensions/pagination.rb +2 -2
  33. data/lib/praxis/extensions/pagination/ordering_params.rb +1 -1
  34. data/lib/praxis/extensions/pagination/pagination_params.rb +6 -4
  35. data/lib/praxis/field_expander.rb +90 -0
  36. data/lib/praxis/finalizable.rb +34 -0
  37. data/lib/praxis/mapper/selector_generator.rb +1 -1
  38. data/lib/praxis/media_type.rb +3 -68
  39. data/lib/praxis/plugin_concern.rb +1 -1
  40. data/lib/praxis/plugins/mapper_plugin.rb +7 -7
  41. data/lib/praxis/renderer.rb +88 -0
  42. data/lib/praxis/request.rb +1 -1
  43. data/lib/praxis/resource_definition.rb +2 -311
  44. data/lib/praxis/response_definition.rb +2 -10
  45. data/lib/praxis/response_template.rb +3 -3
  46. data/lib/praxis/router.rb +2 -2
  47. data/lib/praxis/routing_config.rb +1 -1
  48. data/lib/praxis/tasks/api_docs.rb +13 -63
  49. data/lib/praxis/tasks/routes.rb +1 -1
  50. data/lib/praxis/types/media_type_common.rb +1 -11
  51. data/lib/praxis/version.rb +1 -1
  52. data/praxis.gemspec +0 -1
  53. data/spec/functional_spec.rb +5 -9
  54. data/spec/praxis/action_definition_spec.rb +12 -20
  55. data/spec/praxis/blueprint_spec.rb +373 -0
  56. data/spec/praxis/bootloader_spec.rb +10 -2
  57. data/spec/praxis/collection_spec.rb +0 -13
  58. data/spec/praxis/config_hash_spec.rb +64 -0
  59. data/spec/praxis/{resource_definition_spec.rb → endpoint_definition_spec.rb} +37 -64
  60. data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +4 -6
  61. data/spec/praxis/extensions/field_expansion_spec.rb +5 -24
  62. data/spec/praxis/field_expander_spec.rb +149 -0
  63. data/spec/praxis/media_type_identifier_spec.rb +5 -4
  64. data/spec/praxis/media_type_spec.rb +4 -93
  65. data/spec/praxis/renderer_spec.rb +188 -0
  66. data/spec/praxis/response_definition_spec.rb +0 -31
  67. data/spec/praxis/response_spec.rb +1 -1
  68. data/spec/praxis/router_spec.rb +8 -8
  69. data/spec/praxis/routing_config_spec.rb +3 -3
  70. data/spec/spec_app/app/controllers/instances.rb +13 -7
  71. data/spec/spec_app/design/media_types/instance.rb +1 -19
  72. data/spec/spec_app/design/media_types/volume.rb +1 -1
  73. data/spec/spec_app/design/media_types/volume_snapshot.rb +2 -14
  74. data/spec/spec_app/design/resources/instances.rb +5 -8
  75. data/spec/spec_app/design/resources/volume_snapshots.rb +1 -1
  76. data/spec/spec_app/design/resources/volumes.rb +1 -1
  77. data/spec/support/spec_authorization_plugin.rb +1 -1
  78. data/spec/support/spec_blueprints.rb +72 -0
  79. data/spec/support/{spec_resource_definitions.rb → spec_endpoint_definitions.rb} +2 -2
  80. data/spec/support/spec_media_types.rb +6 -26
  81. data/tasks/thor/app.rb +8 -34
  82. data/tasks/thor/example.rb +45 -285
  83. data/tasks/thor/templates/generator/empty_app/.gitignore +0 -1
  84. data/tasks/thor/templates/generator/empty_app/Gemfile +7 -23
  85. data/tasks/thor/templates/generator/empty_app/README.md +1 -1
  86. data/tasks/thor/templates/generator/empty_app/Rakefile +4 -13
  87. data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.empty_directory +0 -0
  88. data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.gitkeep +0 -0
  89. data/tasks/thor/templates/generator/empty_app/config/environment.rb +25 -17
  90. data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.empty_directory +0 -0
  91. data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.gitkeep +0 -0
  92. data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.empty_directory +0 -0
  93. data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.gitkeep +0 -0
  94. data/tasks/thor/templates/generator/empty_app/docs/.empty_directory +0 -0
  95. data/tasks/thor/templates/generator/empty_app/docs/.gitkeep +0 -0
  96. data/tasks/thor/templates/generator/empty_app/spec/spec_helper.rb +14 -9
  97. data/tasks/thor/templates/generator/example_app/.gitignore +1 -0
  98. data/tasks/thor/templates/generator/example_app/Gemfile +19 -0
  99. data/tasks/thor/templates/generator/example_app/Rakefile +54 -0
  100. data/tasks/thor/templates/generator/example_app/app/models/user.rb +6 -0
  101. data/tasks/thor/templates/generator/example_app/app/v1/controllers/users.rb +17 -0
  102. data/tasks/thor/templates/generator/example_app/app/v1/resources/user.rb +46 -0
  103. data/tasks/thor/templates/generator/example_app/config.ru +31 -0
  104. data/tasks/thor/templates/generator/example_app/config/environment.rb +40 -0
  105. data/tasks/thor/templates/generator/example_app/db/migrate/20201010101010_create_users_table.rb +11 -0
  106. data/tasks/thor/templates/generator/example_app/design/api.rb +18 -0
  107. data/tasks/thor/templates/generator/example_app/design/v1/endpoints/users.rb +37 -0
  108. data/tasks/thor/templates/generator/example_app/design/v1/media_types/user.rb +26 -0
  109. data/tasks/thor/templates/generator/example_app/spec/helpers/database_helper.rb +18 -0
  110. data/tasks/thor/templates/generator/example_app/spec/spec_helper.rb +42 -0
  111. data/tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb +37 -0
  112. metadata +49 -135
  113. data/lib/api_browser/.bowerrc +0 -3
  114. data/lib/api_browser/.editorconfig +0 -21
  115. data/lib/api_browser/Gruntfile.js +0 -581
  116. data/lib/api_browser/app/index.html +0 -59
  117. data/lib/api_browser/app/js/app.js +0 -48
  118. data/lib/api_browser/app/js/controllers/action.js +0 -47
  119. data/lib/api_browser/app/js/controllers/controller.js +0 -10
  120. data/lib/api_browser/app/js/controllers/menu.js +0 -93
  121. data/lib/api_browser/app/js/controllers/trait.js +0 -10
  122. data/lib/api_browser/app/js/controllers/type.js +0 -24
  123. data/lib/api_browser/app/js/directives/attribute_description.js +0 -56
  124. data/lib/api_browser/app/js/directives/attribute_table.js +0 -28
  125. data/lib/api_browser/app/js/directives/conditional_requirements.js +0 -13
  126. data/lib/api_browser/app/js/directives/fixed_if_fits.js +0 -38
  127. data/lib/api_browser/app/js/directives/highlight.js +0 -14
  128. data/lib/api_browser/app/js/directives/menu_item.js +0 -59
  129. data/lib/api_browser/app/js/directives/no_container.js +0 -8
  130. data/lib/api_browser/app/js/directives/readable_list.js +0 -87
  131. data/lib/api_browser/app/js/directives/request_examples.js +0 -31
  132. data/lib/api_browser/app/js/directives/type_placeholder.js +0 -30
  133. data/lib/api_browser/app/js/directives/url.js +0 -15
  134. data/lib/api_browser/app/js/factories/Configuration.js +0 -12
  135. data/lib/api_browser/app/js/factories/Documentation.js +0 -61
  136. data/lib/api_browser/app/js/factories/Example.js +0 -51
  137. data/lib/api_browser/app/js/factories/PageInfo.js +0 -9
  138. data/lib/api_browser/app/js/factories/normalize_attributes.js +0 -20
  139. data/lib/api_browser/app/js/factories/prepare_template.js +0 -15
  140. data/lib/api_browser/app/js/factories/template_for.js +0 -128
  141. data/lib/api_browser/app/js/filters/attribute_name.js +0 -10
  142. data/lib/api_browser/app/js/filters/friendly_json.js +0 -5
  143. data/lib/api_browser/app/js/filters/has_requirement.js +0 -14
  144. data/lib/api_browser/app/js/filters/header_info.js +0 -9
  145. data/lib/api_browser/app/js/filters/is_empty.js +0 -8
  146. data/lib/api_browser/app/js/filters/markdown.js +0 -6
  147. data/lib/api_browser/app/js/filters/resource_name.js +0 -5
  148. data/lib/api_browser/app/js/filters/tag_requirement.js +0 -13
  149. data/lib/api_browser/app/sass/modules/_body.scss +0 -40
  150. data/lib/api_browser/app/sass/modules/_cloke.scss +0 -8
  151. data/lib/api_browser/app/sass/modules/_header.scss +0 -10
  152. data/lib/api_browser/app/sass/modules/_nav.scss +0 -7
  153. data/lib/api_browser/app/sass/modules/_sidebar.scss +0 -134
  154. data/lib/api_browser/app/sass/modules/_switch.scss +0 -55
  155. data/lib/api_browser/app/sass/modules/_table.scss +0 -13
  156. data/lib/api_browser/app/sass/praxis.scss +0 -70
  157. data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +0 -774
  158. data/lib/api_browser/app/views/action.html +0 -97
  159. data/lib/api_browser/app/views/builtin/field-selector.html +0 -24
  160. data/lib/api_browser/app/views/controller.html +0 -55
  161. data/lib/api_browser/app/views/directives/attribute_description.html +0 -2
  162. data/lib/api_browser/app/views/directives/attribute_description/default.html +0 -2
  163. data/lib/api_browser/app/views/directives/attribute_description/example.html +0 -13
  164. data/lib/api_browser/app/views/directives/attribute_description/headers.html +0 -8
  165. data/lib/api_browser/app/views/directives/attribute_description/member_options.html +0 -4
  166. data/lib/api_browser/app/views/directives/attribute_description/values.html +0 -14
  167. data/lib/api_browser/app/views/directives/attribute_table.html +0 -17
  168. data/lib/api_browser/app/views/directives/menu_item.html +0 -8
  169. data/lib/api_browser/app/views/directives/url.html +0 -3
  170. data/lib/api_browser/app/views/examples/general.html +0 -26
  171. data/lib/api_browser/app/views/home.html +0 -5
  172. data/lib/api_browser/app/views/layout.html +0 -8
  173. data/lib/api_browser/app/views/menu.html +0 -42
  174. data/lib/api_browser/app/views/navbar.html +0 -9
  175. data/lib/api_browser/app/views/trait.html +0 -13
  176. data/lib/api_browser/app/views/type.html +0 -6
  177. data/lib/api_browser/app/views/type/details.html +0 -33
  178. data/lib/api_browser/app/views/types/embedded/array.html +0 -2
  179. data/lib/api_browser/app/views/types/embedded/default.html +0 -12
  180. data/lib/api_browser/app/views/types/embedded/field-selector.html +0 -13
  181. data/lib/api_browser/app/views/types/embedded/links.html +0 -11
  182. data/lib/api_browser/app/views/types/embedded/requirements.html +0 -6
  183. data/lib/api_browser/app/views/types/embedded/single_req.html +0 -9
  184. data/lib/api_browser/app/views/types/embedded/struct.html +0 -14
  185. data/lib/api_browser/app/views/types/label/link.html +0 -1
  186. data/lib/api_browser/app/views/types/label/primitive.html +0 -1
  187. data/lib/api_browser/app/views/types/label/primitive_collection.html +0 -1
  188. data/lib/api_browser/app/views/types/label/type.html +0 -1
  189. data/lib/api_browser/app/views/types/label/type_collection.html +0 -1
  190. data/lib/api_browser/app/views/types/main/array.html +0 -22
  191. data/lib/api_browser/app/views/types/main/default.html +0 -23
  192. data/lib/api_browser/app/views/types/main/hash.html +0 -23
  193. data/lib/api_browser/app/views/types/standalone/array.html +0 -3
  194. data/lib/api_browser/app/views/types/standalone/default.html +0 -18
  195. data/lib/api_browser/app/views/types/standalone/struct.html +0 -2
  196. data/lib/api_browser/bower_template.json +0 -41
  197. data/lib/api_browser/package-lock.json +0 -7110
  198. data/lib/api_browser/package.json +0 -43
  199. data/lib/praxis/docs/generator.rb +0 -243
  200. data/lib/praxis/docs/link_builder.rb +0 -30
  201. data/lib/praxis/links.rb +0 -135
  202. data/lib/praxis/types/multipart.rb +0 -109
  203. data/spec/api_browser/directives/type_placeholder_spec.js +0 -134
  204. data/spec/api_browser/factories/configuration_spec.js +0 -32
  205. data/spec/api_browser/factories/documentation_spec.js +0 -100
  206. data/spec/api_browser/factories/normalize_attributes_spec.js +0 -92
  207. data/spec/api_browser/factories/template_for_spec.js +0 -67
  208. data/spec/api_browser/filters/attribute_name_spec.js +0 -23
  209. data/spec/praxis/types/multipart_spec.rb +0 -112
  210. data/tasks/thor/templates/generator/empty_app/.rspec +0 -1
  211. data/tasks/thor/templates/generator/empty_app/Guardfile +0 -3
  212. data/tasks/thor/templates/generator/empty_app/config/rainbows.rb +0 -57
  213. data/tasks/thor/templates/generator/empty_app/docs/app.js +0 -1
  214. data/tasks/thor/templates/generator/empty_app/docs/styles.scss +0 -3
@@ -1,59 +0,0 @@
1
- app.directive('menuItem', function($compile, $stateParams) {
2
-
3
- function checkIfShouldShow(scope, params) {
4
- var currentId = params.action ? params.controller + '_action_' + params.action : (params.controller || params.type || params.trait);
5
- scope.isActive = scope.link.id === currentId;
6
-
7
- function checkLink(link) {
8
- if (link.id === currentId || link.parent === currentId) {
9
- return true;
10
- } else {
11
- if (link.parentRef) {
12
- var matches = function(r) { return r.id === currentId; };
13
- if (!link.isAction) {
14
- if ((link.parentRef.childResources || []).some(matches)) return true;
15
- }
16
- if ((link.parentRef.actions || []).some(matches)) return true;
17
- }
18
-
19
- return (link.childResources || []).some(checkLink) || (link.actions || []).some(checkLink);
20
- }
21
- }
22
- scope.shouldShow = scope.toplevel || checkLink(scope.link);
23
- }
24
-
25
- function link(scope) {
26
- scope.$on('$stateChangeSuccess', function(e, state, params) {
27
- checkIfShouldShow(scope, params);
28
- });
29
- checkIfShouldShow(scope, $stateParams);
30
- }
31
-
32
- return {
33
- restrict: 'E',
34
- templateUrl: 'views/directives/menu_item.html',
35
- scope: {
36
- link: '=',
37
- toplevel: '='
38
- },
39
- // hackery to make a recursive directive
40
- compile: function(element) {
41
- var contents = element.contents().remove();
42
- var compiledContents;
43
- return {
44
- post: function(scope, element){
45
- // Compile the contents
46
- if(!compiledContents) {
47
- compiledContents = $compile(contents);
48
- }
49
- // Re-add the compiled contents to the element
50
- compiledContents(scope, function(clone) {
51
- element.append(clone);
52
- });
53
-
54
- link(scope, element);
55
- }
56
- };
57
- }
58
- };
59
- });
@@ -1,8 +0,0 @@
1
- app.directive('noContainer', function() {
2
- return {
3
- restrict: 'A',
4
- link: function(scope, element){
5
- element.replaceWith(element.children());
6
- }
7
- };
8
- });
@@ -1,87 +0,0 @@
1
- app.factory('Repeater', function() {
2
- function Repeater(expression) {
3
- var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
4
-
5
- var lhs = match[1];
6
- this.rhs = match[2];
7
- this.aliasAs = match[3];
8
- this.trackByExp = match[4];
9
-
10
- match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
11
-
12
- this.valueIdentifier = match[3] || match[1];
13
- this.keyIdentifier = match[2];
14
- }
15
-
16
- Repeater.prototype.$watch = function(fn) {
17
- this.$scope.$watchCollection(this.rhs, fn);
18
- };
19
-
20
- Repeater.prototype.$transclude = function(length, value, key, index, fn) {
21
- var self = this;
22
- self._transclude(function(clone, scope) {
23
- scope[self.valueIdentifier] = value;
24
- if (self.keyIdentifier) scope[self.keyIdentifier] = key;
25
- scope.$index = index;
26
- scope.$first = (index === 0);
27
- scope.$last = (index === (length - 1));
28
- scope.$middle = !(scope.$first || scope.$last);
29
- // jshint bitwise: false
30
- scope.$odd = !(scope.$even = (index&1) === 0);
31
- // jshint bitwise: true
32
- fn(clone, scope);
33
- });
34
- };
35
-
36
- return {
37
- compile: function(repeatAttr, linkFn) {
38
- return function(element, attrs) {
39
- var expression = attrs[repeatAttr];
40
- var repeater = new Repeater(expression);
41
- return function($scope, $element, $attr, ctrl, $transclude) {
42
- repeater._transclude = $transclude;
43
- repeater.$scope = $scope;
44
- linkFn($scope, $element, $attr, ctrl, repeater);
45
- };
46
- };
47
- }
48
- };
49
- });
50
- app.directive('readableList', function(Repeater) {
51
-
52
- return {
53
- restrict: 'E',
54
- transclude: true,
55
- compile: Repeater.compile('repeat', function($scope, $element, $attr, ctrl, $repeat) {
56
- $repeat.$watch(function(inputList) {
57
- $element.empty();
58
- if (inputList.length == 1) {
59
- $repeat.$transclude(1, inputList[0], null, 0, function(clone) {
60
- $element.append(clone);
61
- });
62
- } else {
63
- var finalJoin = ' and ';
64
-
65
- var join = ', ',
66
- arr = inputList.slice(0),
67
- last = arr.pop(),
68
- beforeLast = arr.pop();
69
-
70
- _.each(arr, function(data, index) {
71
- $repeat.$transclude(inputList.length, data, null, index, function(clone) {
72
- $element.append(clone);
73
- $element.append(document.createTextNode(join));
74
- });
75
- });
76
- $repeat.$transclude(inputList.length, beforeLast, null, inputList.length - 2, function(clone) {
77
- $element.append(clone);
78
- $element.append(document.createTextNode(finalJoin));
79
- });
80
- $repeat.$transclude(inputList.length, last, null, inputList.length - 1, function(clone) {
81
- $element.append(clone);
82
- });
83
- }
84
- });
85
- })
86
- };
87
- });
@@ -1,31 +0,0 @@
1
- app.directive('requestExamples', function(Examples, $timeout) {
2
- return {
3
- restrict: 'E',
4
- scope: {
5
- action: '=',
6
- resource: '=',
7
- version: '='
8
- },
9
- template: '<tabset><tab ng-repeat="example in examples" heading="{{example.displayName}}" select="select(example.template)"></tab></tabset>',
10
- link: function(scope, element) {
11
- scope.examples = Examples.forContext(scope.action, scope.version, scope.resource);
12
- var keys = _.keys(scope.examples);
13
- if (keys.length === 1) {
14
- scope.examples[keys[0]].template.then(function(templateFn) {
15
- $timeout(function() {
16
- element.empty().append(templateFn(scope));
17
- }, 100);
18
- });
19
- } else {
20
- scope.select = function(template) {
21
- template.then(function(templateFn) {
22
- $timeout(function() {
23
- element.find('.tab-content:eq(0)>.tab-pane.active:not(.initialized)').append(templateFn(scope)).addClass('initialized');
24
- template.then = _.noop;
25
- }, 100);
26
- });
27
- };
28
- }
29
- }
30
- };
31
- });
@@ -1,30 +0,0 @@
1
- /**
2
- * This directive replaces itself with a specialised type template based on the
3
- * type it is displaying.
4
- */
5
- app.directive('typePlaceholder', function(templateFor, $stateParams) {
6
- return {
7
- restrict: 'EA',
8
- scope: {
9
- type: '=',
10
- template: '@',
11
- details: '=?',
12
- name: '=?',
13
- parentRequirements: '=?',
14
- },
15
- link: function(scope, element) {
16
-
17
- scope.apiVersion = $stateParams.version;
18
-
19
- if( typeof scope.parentRequirements === 'undefined' ){
20
- if( typeof scope.type.requirements !== 'undefined' && scope.type.requirements.length > 0 ){
21
- scope.parentRequirements = scope.type.requirements;
22
- }
23
- }
24
-
25
- templateFor(scope.type, scope.template).then(function(templateFn) {
26
- element.replaceWith(templateFn(scope));
27
- });
28
- }
29
- };
30
- });
@@ -1,15 +0,0 @@
1
- /**
2
- * This directive is responsible to render a URL for an action
3
- */
4
- app.directive('url', function() {
5
- return {
6
- restrict: 'EA',
7
- scope: {
8
- action: '='
9
- },
10
- templateUrl: 'views/directives/url.html',
11
- link: function(scope, element, attrs) {
12
- scope.showExample = 'example' in attrs;
13
- }
14
- };
15
- });
@@ -1,12 +0,0 @@
1
- // Use this to provide settings for the doc browser
2
- app.provider('Configuration', function() {
3
- this.title = 'API Browser';
4
- this.versionLabel = 'API Version';
5
- this.expandChildren = true;
6
-
7
- this.$get = function() {
8
- return this;
9
- };
10
- }).run(function(Configuration, $rootScope) {
11
- _.extend($rootScope, _.omit(Configuration, '$get'));
12
- });
@@ -1,61 +0,0 @@
1
- /**
2
- * This service gives access to the documentation metadata
3
- */
4
- app.factory('Documentation', function($http, $q) {
5
- var versions = $q.when($http.get('api/index-new.json', { cache: true }).then(function(data) {
6
- return $q.all(_.map(data.data.versions, function(version) {
7
- return $http.get('api/' + version + '.json', {cache: true}).then(function(versionData) {
8
- return [version, versionData.data];
9
- });
10
- })).then(_.zipObject);
11
- }));
12
-
13
- return {
14
- /**
15
- * Returns an array of version strings
16
- */
17
- versions: function() {
18
- return versions.then(_.keys);
19
- },
20
- /**
21
- * Returns the info for the requested version
22
- */
23
- info: function(version) {
24
- return versions.then(function(v) { return v[version].info; });
25
- },
26
- /**
27
- * Returns a list of controllers and types, useful for generating navigation
28
- */
29
- items: function(version) {
30
- return versions.then(function(v) { return v[version]; });
31
- },
32
- /**
33
- * Returns description of a controller
34
- */
35
- controller: function(version, name) {
36
- return this.items(version).then(function(v) {
37
- var controller = v.resources[name];
38
- controller.id = name;
39
- return controller;
40
- });
41
- },
42
-
43
- /**
44
- * Returns a description of a type
45
- */
46
- type: function(version, name) {
47
- return versions.then(function(v) {
48
- return v[version].schemas[name];
49
- });
50
- },
51
-
52
- /**
53
- * Returns a description of a trait
54
- */
55
- trait: function(version, name) {
56
- return versions.then(function(v) {
57
- return v[version].traits[name];
58
- });
59
- }
60
- };
61
- });
@@ -1,51 +0,0 @@
1
- app.provider('Examples', function() {
2
- var registry = {};
3
-
4
- this.register = function(key, displayName, handler) {
5
- registry[key] = registry[key] || [];
6
- registry[key].unshift({
7
- key: key,
8
- displayName: displayName,
9
- handler: handler
10
- });
11
- };
12
-
13
- this.removeHandlersForKey = function(key) {
14
- registry[key] = [];
15
- };
16
-
17
- this.register('general', 'General', function() {
18
- return 'views/examples/general.html';
19
- });
20
-
21
- this.$get = function(prepareTemplate, $injector) {
22
- return {
23
- forContext: function(action, version, resource) {
24
- var results = {};
25
- for (var key in registry) {
26
- for (var i = 0; i < registry[key].length; i++) {
27
- var result = $injector.invoke(registry[key][i].handler, this, {
28
- $action: action,
29
- $version: version,
30
- $context: {
31
- resource: resource,
32
- action: action,
33
- version: version
34
- }
35
- });
36
- if (result) {
37
- results[key] = {
38
- key: key,
39
- displayName: registry[key][i].displayName,
40
- template: prepareTemplate(result)
41
- };
42
- break;
43
- }
44
- }
45
- }
46
- return results;
47
- }
48
- };
49
- };
50
-
51
- });
@@ -1,9 +0,0 @@
1
- app.service('PageInfo', function($rootScope) {
2
- this.title = null;
3
- var self = this;
4
- $rootScope.$watch(function() {
5
- return self.title;
6
- }, function() {
7
- $rootScope.subtitle = self.title;
8
- });
9
- });
@@ -1,20 +0,0 @@
1
- app.factory('normalizeAttributes', function() {
2
- function normalize(type, attributes, parent) {
3
- _.forEach(attributes, function(attribute, name) {
4
- var path = parent.concat([name]);
5
- if (!attribute.options) attribute.options = {};
6
- if (attribute.values != null) attribute.options.values = attribute.values;
7
- if (attribute.default != null) attribute.options.default = attribute.default;
8
- if (attribute.example != null) attribute.options.example = attribute.example;
9
- if ( attribute.type.attributes ) {
10
- normalize(attribute.type, attribute.type.attributes, path);
11
- }else if( attribute.type.member_attribute ){
12
- normalize(attribute.type.member_attribute.type, attribute.type.member_attribute.type.attributes, path);
13
- }
14
- });
15
- }
16
-
17
- return function(type, attributes) {
18
- normalize(type, attributes, []);
19
- };
20
- });
@@ -1,15 +0,0 @@
1
- app.factory('prepareTemplate', function($q, $http, $templateCache, $compile) {
2
- return function(result) {
3
- return $q.when(result).then(function(template) {
4
- if (_.isFunction(template)) {
5
- return template;
6
- } else if (_.isString(template)) {
7
- return $http.get(template, {cache: $templateCache}).then(function(response) {
8
- return $compile(response.data);
9
- });
10
- } else {
11
- throw 'Resolver returned an unknown type';
12
- }
13
- });
14
- };
15
- });
@@ -1,128 +0,0 @@
1
- /**
2
- * Allows dynamic UI based on resolvers. You can customise the way templates
3
- * work in the doc browser by registering your own template resolver.
4
- *
5
- * A template resolver is dependency injected function that has several special
6
- * arguments that can be injected. These are:
7
- *
8
- * Name | Type | Description
9
- * --------------------|---------|----------------------------------------------
10
- * $type | String | The name of a type.
11
- * $family | String | The family or group of types this type belongs to.
12
- * $typeDefinition | Object | The full definition of the type as available.
13
- * $requestedTemplate | String | This is the kind of template that we want. Possible values are: standalone, embedded and label. Embedded templates represent types that are attributes of another type. The template thus should assume that it is being rendered in a table row. Label templates display a human readable name of a type. Standalone templates are used when a type is displayed by itself (i.e. a request payload).
14
- *
15
- * The type resolver should return either a $compiled template, or a url of a
16
- * template or a promise for one of those. In that case the template resolution
17
- * procedure will halt and the returned template will be displayed. If `undefined`
18
- * is passed, the next resolver will be invoked. A promise for undefined is currently
19
- * not supported.
20
- */
21
- app.provider('templateFor', function() {
22
-
23
- var resolvers = [];
24
- /**
25
- * Register a custom template resolver.
26
- * @param {function} resolver
27
- * A function that returns undefined or a promise for a compiled template or a template url.
28
- */
29
- this.register = function(resolver) {
30
- resolvers.unshift(resolver);
31
- };
32
-
33
- this.register(function payloadResolver($family, $requestedTemplate) {
34
- 'ngInject';
35
- if ($requestedTemplate === 'standalone') {
36
- switch ($family) {
37
- case 'hash':
38
- return 'views/types/standalone/struct.html';
39
- case 'array':
40
- return 'views/types/standalone/array.html';
41
- default:
42
- return 'views/types/standalone/default.html';
43
- }
44
- }
45
- });
46
-
47
- this.register(function typeResolver($family, $type, $requestedTemplate) {
48
- 'ngInject';
49
- if ($requestedTemplate === 'embedded') {
50
- if ($type === 'Links') {
51
- return 'views/types/embedded/links.html';
52
- }
53
- if ($type === 'Praxis::Extensions::FieldSelection::FieldSelector') {
54
- return 'views/types/embedded/field-selector.html';
55
- }
56
- switch ($family) {
57
- case 'hash':
58
- return 'views/types/embedded/struct.html';
59
- case 'array':
60
- return 'views/types/embedded/array.html';
61
- default:
62
- return 'views/types/embedded/default.html';
63
- }
64
- }
65
- });
66
-
67
- this.register(function labelResolver($typeDefinition, $requestedTemplate, primitives) {
68
- 'ngInject';
69
- if ($requestedTemplate === 'label') {
70
- if ( $typeDefinition.member_attribute !== undefined) {
71
- if ($typeDefinition.member_attribute.anonymous || _.contains(primitives, $typeDefinition.member_attribute.type.name)) {
72
- return 'views/types/label/primitive_collection.html';
73
- } else{
74
- return 'views/types/label/type_collection.html';
75
- }
76
- } else if ($typeDefinition.anonymous || _.contains(primitives, $typeDefinition.name)) {
77
- return 'views/types/label/primitive.html';
78
- } else if ($typeDefinition.link_to) {
79
- return 'views/types/label/link.html';
80
- }
81
- return 'views/types/label/type.html';
82
- }
83
- });
84
-
85
- this.register(function mainPageResolver($family, $requestedTemplate) {
86
- 'ngInject';
87
- if ($requestedTemplate === 'main') {
88
- switch ($family) {
89
- case 'hash':
90
- return 'views/types/main/hash.html';
91
- case 'array':
92
- return 'views/types/main/array.html';
93
- default:
94
- return 'views/types/main/default.html';
95
- }
96
- }
97
- });
98
-
99
- this.$get = function($injector, prepareTemplate) {
100
- return function(type, templateType) {
101
- for (var i = 0; i < resolvers.length; i++) {
102
- var result = $injector.invoke(resolvers[i], this, {
103
- $type: type.name,
104
- $typeDefinition: type,
105
- $family: type.family || type.name,
106
- $requestedTemplate: templateType
107
- });
108
- if (result) {
109
- return prepareTemplate(result);
110
- }
111
- }
112
- throw 'Template did not match any resolver.';
113
- };
114
- };
115
- })
116
- .constant('primitives', [
117
- 'Boolean',
118
- 'CSV',
119
- 'DateTime',
120
- 'Float',
121
- 'Hash',
122
- 'Ids',
123
- 'Integer',
124
- 'Object',
125
- 'String',
126
- 'Struct',
127
- 'URI'
128
- ]);