Source: models/Depot.js

  1. var assign = require('object-assign');
  2. var Node = require('./Node');
  3. /**
  4. * Initialize a new depot instance.
  5. *
  6. * @param {Object} obj Data from the server, which doesn't follow typical
  7. * javaScript naming conventions.
  8. * @constructor
  9. * @memberof models
  10. */
  11. function Depot(obj) {
  12. this._data = obj || {};
  13. /**
  14. * The immediate directories and files under this depot.
  15. *
  16. * @type {Array<PathItem>}
  17. */
  18. this.children = [];
  19. var self = this;
  20. Object.defineProperties(this, {
  21. /**
  22. * The name of the Depot
  23. *
  24. * @type string
  25. * @name models.Depot#depot
  26. * @memberOf models.Depot
  27. */
  28. 'depot': {
  29. get: function() {
  30. return self._data['Depot'];
  31. },
  32. set: function(x) {
  33. self._data['Depot'] = x;
  34. return x;
  35. }
  36. },
  37. /**
  38. * The created date of the depot
  39. *
  40. * @type Date
  41. * @name models.Depot#date
  42. * @memberOf models.Depot
  43. * @readonly
  44. */
  45. 'date': {
  46. get: function() {
  47. if (self._data['Date']) {
  48. return new Date(self._data['Date']);
  49. }
  50. }
  51. },
  52. /**
  53. * The Depot type, one of 'local', 'remote', 'spec', 'stream', 'unload', or
  54. * 'archive'.
  55. *
  56. * @type string
  57. * @name models.Depot#type
  58. * @memberOf models.Depot
  59. */
  60. 'type': {
  61. get: function() {
  62. return self._date['Type'];
  63. },
  64. set: function(x) {
  65. // TODO validate x
  66. self._date['Type'] = x;
  67. }
  68. },
  69. /**
  70. * If `type` is 'remote', this is the P4PORT address of the remote server.
  71. *
  72. * @type string
  73. * @name models.Depot#address
  74. * @memberOf models.Depot
  75. */
  76. 'address': {
  77. get: function() {
  78. return self._date['Address'];
  79. },
  80. set: function(x) {
  81. self._date['Type'] = x;
  82. }
  83. },
  84. /**
  85. * If `type` is 'local', 'spec', or 'archive', this points to the relative
  86. * location of the depot subdirectory.
  87. *
  88. * @type string
  89. * @name models.Depot#map
  90. * @memberOf models.Depot
  91. */
  92. 'map': {
  93. get: function() {
  94. return self._date['Map'];
  95. },
  96. set: function(x) {
  97. self._date['Map'] = x;
  98. return x;
  99. }
  100. },
  101. /**
  102. * A short description of the depot's purpose.
  103. *
  104. * @type string
  105. * @name models.Depot#description
  106. * @memberOf models.Depot
  107. */
  108. 'description': {
  109. get: function() {
  110. return self._date['Description'];
  111. },
  112. set: function(x) {
  113. self._date['Description'] = x;
  114. return x;
  115. }
  116. },
  117. /**
  118. * The user login that owns the Depot.
  119. *
  120. * @type string
  121. * @name models.Depot#owner
  122. * @memberOf models.Depot
  123. */
  124. 'owner': {
  125. get: function() {
  126. return self._data['Owner'];
  127. },
  128. set: function(x) {
  129. self._data['Owner'] = x;
  130. return x;
  131. }
  132. },
  133. /**
  134. * If the `type` is 'spec', this holds an optional suffix for generated
  135. * paths to objects in the spec depot.
  136. *
  137. * @type string
  138. * @name models.Depot#suffix
  139. * @memberOf models.Depot
  140. */
  141. 'suffix': {
  142. get: function() {
  143. return self._data['Suffix'];
  144. },
  145. set: function(x) {
  146. self._data['Suffix'] = x;
  147. return x;
  148. }
  149. },
  150. /**
  151. * When type is 'spec', this an optional description of what specs should
  152. * be saved.
  153. *
  154. * @type string
  155. * @name models.Depot#specMap
  156. * @memberOf models.Depot
  157. */
  158. 'specMap': {
  159. get: function() {
  160. return self._data['SpecMap'];
  161. }
  162. },
  163. /**
  164. * The representation of the depot suitable to POST back to the Helix
  165. * Web Services Perforce API.
  166. *
  167. * @type object
  168. * @name models.Depot#data
  169. * @memberOf models.Depot
  170. * @readonly
  171. */
  172. 'data': {
  173. get: function() {
  174. return self._data;
  175. }
  176. },
  177. /**
  178. * Used by our underlying Node representation
  179. *
  180. * @type string
  181. * @name models.Depot#name
  182. * @memberOf models.Depot
  183. * @readonly
  184. */
  185. 'name': {
  186. get: function() {
  187. return self.depot;
  188. }
  189. },
  190. /**
  191. * Used by our underlying Node representation
  192. *
  193. * @type string
  194. * @name models.Depot#pathId
  195. * @memberOf models.Depot
  196. * @readonly
  197. */
  198. 'pathId': {
  199. get: function() {
  200. return [self.depot];
  201. }
  202. }
  203. });
  204. }
  205. assign(Depot.prototype, Node);
  206. module.exports = Depot;