@builttocreate/engine-utils 2.0.0 → 2.1.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.
- package/dist/constants/DocumentTypes.js +13 -0
- package/dist/joyDocHelper.js +80 -2
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var types = {
|
|
8
|
+
document: 'document',
|
|
9
|
+
template: 'template',
|
|
10
|
+
version: 'version'
|
|
11
|
+
};
|
|
12
|
+
var _default = types;
|
|
13
|
+
exports["default"] = _default;
|
package/dist/joyDocHelper.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getDefaultJoyDocPage = exports.getDefaultJoyDocFile = exports.getDefaultJoyDoc = exports.getCleanedJoyDocPages = exports.getCleanedJoyDoc = exports["default"] = void 0;
|
|
8
|
+
exports.getDocumentFromTemplate = exports.getDefaultTemplate = exports.getDefaultJoyDocPage = exports.getDefaultJoyDocFile = exports.getDefaultJoyDoc = exports.getDefaultDocument = exports.getCleanedJoyDocPages = exports.getCleanedJoyDoc = exports["default"] = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
@@ -17,6 +17,8 @@ var _PageLayoutModes = _interopRequireDefault(require("./constants/PageLayoutMod
|
|
|
17
17
|
|
|
18
18
|
var _FieldPresentationModes = _interopRequireDefault(require("./constants/FieldPresentationModes"));
|
|
19
19
|
|
|
20
|
+
var _DocumentTypes = _interopRequireDefault(require("./constants/DocumentTypes"));
|
|
21
|
+
|
|
20
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
23
|
|
|
22
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -199,13 +201,89 @@ var getCleanedJoyDocPages = function getCleanedJoyDocPages(pages) {
|
|
|
199
201
|
return [getDefaultJoyDocPage()];
|
|
200
202
|
}
|
|
201
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Get a properly formatted Document JoyDoc
|
|
206
|
+
*
|
|
207
|
+
* @returns {Object}
|
|
208
|
+
*/
|
|
209
|
+
|
|
202
210
|
|
|
203
211
|
exports.getCleanedJoyDocPages = getCleanedJoyDocPages;
|
|
212
|
+
|
|
213
|
+
var getDefaultDocument = function getDefaultDocument() {
|
|
214
|
+
var type = _DocumentTypes["default"].document;
|
|
215
|
+
|
|
216
|
+
var _id = (0, _generateObjectId["default"])();
|
|
217
|
+
|
|
218
|
+
var identifier = "doc_".concat(_id);
|
|
219
|
+
var name = 'New Doc';
|
|
220
|
+
return getDefaultJoyDoc({
|
|
221
|
+
type: type,
|
|
222
|
+
_id: _id,
|
|
223
|
+
identifier: identifier,
|
|
224
|
+
name: name
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Get a properly formatted Template JoyDoc
|
|
229
|
+
*
|
|
230
|
+
* @returns {Object}
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
exports.getDefaultDocument = getDefaultDocument;
|
|
235
|
+
|
|
236
|
+
var getDefaultTemplate = function getDefaultTemplate() {
|
|
237
|
+
var type = _DocumentTypes["default"].template;
|
|
238
|
+
|
|
239
|
+
var _id = (0, _generateObjectId["default"])();
|
|
240
|
+
|
|
241
|
+
var identifier = "template_".concat(_id);
|
|
242
|
+
var name = 'New Template';
|
|
243
|
+
return getDefaultJoyDoc({
|
|
244
|
+
type: type,
|
|
245
|
+
_id: _id,
|
|
246
|
+
identifier: identifier,
|
|
247
|
+
name: name
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Get a properly formatted Document JoyDoc from Template JoyDoc
|
|
252
|
+
*
|
|
253
|
+
* @param {Object} template
|
|
254
|
+
* @returns {Object}
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
exports.getDefaultTemplate = getDefaultTemplate;
|
|
259
|
+
|
|
260
|
+
var getDocumentFromTemplate = function getDocumentFromTemplate(template) {
|
|
261
|
+
var _id = (0, _generateObjectId["default"])();
|
|
262
|
+
|
|
263
|
+
var identifier = "doc_".concat(_id); //Remove all references to original template object
|
|
264
|
+
|
|
265
|
+
var temp = JSON.parse(JSON.stringify(template));
|
|
266
|
+
return {
|
|
267
|
+
_id: _id,
|
|
268
|
+
identifier: identifier,
|
|
269
|
+
type: _DocumentTypes["default"].document,
|
|
270
|
+
name: temp.name,
|
|
271
|
+
template: temp.identifier,
|
|
272
|
+
source: temp.identifier,
|
|
273
|
+
files: temp.files,
|
|
274
|
+
fields: temp.fields
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
exports.getDocumentFromTemplate = getDocumentFromTemplate;
|
|
204
279
|
var _default = {
|
|
205
280
|
getDefaultJoyDocPage: getDefaultJoyDocPage,
|
|
206
281
|
getDefaultJoyDocFile: getDefaultJoyDocFile,
|
|
207
282
|
getDefaultJoyDoc: getDefaultJoyDoc,
|
|
208
283
|
getCleanedJoyDoc: getCleanedJoyDoc,
|
|
209
|
-
getCleanedJoyDocPages: getCleanedJoyDocPages
|
|
284
|
+
getCleanedJoyDocPages: getCleanedJoyDocPages,
|
|
285
|
+
getDefaultDocument: getDefaultDocument,
|
|
286
|
+
getDefaultTemplate: getDefaultTemplate,
|
|
287
|
+
getDocumentFromTemplate: getDocumentFromTemplate
|
|
210
288
|
};
|
|
211
289
|
exports["default"] = _default;
|