@kaspernj/api-maker 1.0.2054 → 1.0.2055
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/build/api.js +64 -212
- package/build/api.js.map +1 -1
- package/build/attribute-not-loaded-error.js +2 -25
- package/build/attribute-not-loaded-error.js.map +1 -1
- package/build/base-component.js +3 -26
- package/build/base-component.js.map +1 -1
- package/build/base-error.js +20 -45
- package/build/base-error.js.map +1 -1
- package/build/base-model/attribute.js +14 -21
- package/build/base-model/attribute.js.map +1 -1
- package/build/base-model/column.js +4 -8
- package/build/base-model/column.js.map +1 -1
- package/build/base-model/reflection.js +11 -51
- package/build/base-model/reflection.js.map +1 -1
- package/build/base-model/scope.js +8 -45
- package/build/base-model/scope.js.map +1 -1
- package/build/base-model.js +583 -836
- package/build/base-model.js.map +1 -1
- package/build/bootstrap/attribute-row.js +87 -172
- package/build/bootstrap/attribute-row.js.map +1 -1
- package/build/bootstrap/attribute-rows.js +21 -50
- package/build/bootstrap/attribute-rows.js.map +1 -1
- package/build/bootstrap/card.js +76 -159
- package/build/bootstrap/card.js.map +1 -1
- package/build/bootstrap/checkbox.js +53 -102
- package/build/bootstrap/checkbox.js.map +1 -1
- package/build/bootstrap/checkboxes.js +116 -202
- package/build/bootstrap/checkboxes.js.map +1 -1
- package/build/bootstrap/input.js +80 -131
- package/build/bootstrap/input.js.map +1 -1
- package/build/bootstrap/invalid-feedback.js +18 -46
- package/build/bootstrap/invalid-feedback.js.map +1 -1
- package/build/bootstrap/paginate.js +99 -164
- package/build/bootstrap/paginate.js.map +1 -1
- package/build/bootstrap/radio-buttons.js +43 -80
- package/build/bootstrap/radio-buttons.js.map +1 -1
- package/build/bootstrap/select.js +43 -90
- package/build/bootstrap/select.js.map +1 -1
- package/build/bootstrap/sort-link.js +68 -151
- package/build/bootstrap/sort-link.js.map +1 -1
- package/build/cable-connection-pool.js +43 -65
- package/build/cable-connection-pool.js.map +1 -1
- package/build/cable-subscription-pool.js +104 -161
- package/build/cable-subscription-pool.js.map +1 -1
- package/build/cable-subscription.js +9 -16
- package/build/cable-subscription.js.map +1 -1
- package/build/cache-key-generator.js +27 -36
- package/build/cache-key-generator.js.map +1 -1
- package/build/can-can.js +80 -201
- package/build/can-can.js.map +1 -1
- package/build/channels-consumer.js +5 -10
- package/build/channels-consumer.js.map +1 -1
- package/build/collection-loader.js +35 -53
- package/build/collection-loader.js.map +1 -1
- package/build/collection.js +160 -307
- package/build/collection.js.map +1 -1
- package/build/command-submit-data.d.ts +1 -1
- package/build/command-submit-data.d.ts.map +1 -1
- package/build/command-submit-data.js +29 -38
- package/build/command-submit-data.js.map +1 -1
- package/build/commands-pool.js +139 -215
- package/build/commands-pool.js.map +1 -1
- package/build/compose.js +3 -11
- package/build/compose.js.map +1 -1
- package/build/config.js +20 -67
- package/build/config.js.map +1 -1
- package/build/custom-error.js +4 -29
- package/build/custom-error.js.map +1 -1
- package/build/data-set-to-attributes.js +5 -41
- package/build/data-set-to-attributes.js.map +1 -1
- package/build/deserializer.js +26 -79
- package/build/deserializer.js.map +1 -1
- package/build/destroy-error.js +4 -29
- package/build/destroy-error.js.map +1 -1
- package/build/devise.js +83 -187
- package/build/devise.js.map +1 -1
- package/build/draggable-sort/controller.js +87 -110
- package/build/draggable-sort/controller.js.map +1 -1
- package/build/draggable-sort/index.js +67 -144
- package/build/draggable-sort/index.js.map +1 -1
- package/build/draggable-sort/item.js +131 -197
- package/build/draggable-sort/item.js.map +1 -1
- package/build/error-logger.js +78 -163
- package/build/error-logger.js.map +1 -1
- package/build/error-messages.js +4 -7
- package/build/error-messages.js.map +1 -1
- package/build/event-connection.js +23 -61
- package/build/event-connection.js.map +1 -1
- package/build/event-emitter-listener.js +6 -23
- package/build/event-emitter-listener.js.map +1 -1
- package/build/event-model-class.js +19 -46
- package/build/event-model-class.js.map +1 -1
- package/build/events.js +3 -8
- package/build/events.js.map +1 -1
- package/build/form.js +65 -153
- package/build/form.js.map +1 -1
- package/build/history-expo.js +12 -24
- package/build/history-expo.js.map +1 -1
- package/build/history-react-native.js +14 -26
- package/build/history-react-native.js.map +1 -1
- package/build/history.js +2 -4
- package/build/history.js.map +1 -1
- package/build/index.js +2 -5
- package/build/index.js.map +1 -1
- package/build/inputs/attachment.js +71 -122
- package/build/inputs/attachment.js.map +1 -1
- package/build/inputs/auto-submit.js +15 -54
- package/build/inputs/auto-submit.js.map +1 -1
- package/build/inputs/checkbox.js +77 -166
- package/build/inputs/checkbox.js.map +1 -1
- package/build/inputs/checkboxes.js +75 -158
- package/build/inputs/checkboxes.js.map +1 -1
- package/build/inputs/id-for-component.js +4 -40
- package/build/inputs/id-for-component.js.map +1 -1
- package/build/inputs/input-wrapper.js +7 -26
- package/build/inputs/input-wrapper.js.map +1 -1
- package/build/inputs/input.js +158 -244
- package/build/inputs/input.js.map +1 -1
- package/build/inputs/money.js +123 -185
- package/build/inputs/money.js.map +1 -1
- package/build/inputs/name-for-component.js +4 -40
- package/build/inputs/name-for-component.js.map +1 -1
- package/build/inputs/select.js +68 -122
- package/build/inputs/select.js.map +1 -1
- package/build/instance-of-class-name.js +15 -20
- package/build/instance-of-class-name.js.map +1 -1
- package/build/is-expo.js +8 -10
- package/build/is-expo.js.map +1 -1
- package/build/key-value-store.js +51 -127
- package/build/key-value-store.js.map +1 -1
- package/build/link.js +51 -114
- package/build/link.js.map +1 -1
- package/build/logger.js +19 -25
- package/build/logger.js.map +1 -1
- package/build/merge-styles.js +5 -9
- package/build/merge-styles.js.map +1 -1
- package/build/modal.js +14 -61
- package/build/modal.js.map +1 -1
- package/build/model-class-require.js +8 -43
- package/build/model-class-require.js.map +1 -1
- package/build/model-events.js +24 -33
- package/build/model-events.js.map +1 -1
- package/build/model-name.js +15 -56
- package/build/model-name.js.map +1 -1
- package/build/model-prop-type.js +51 -62
- package/build/model-prop-type.js.map +1 -1
- package/build/model-recipes-loader.js +16 -24
- package/build/model-recipes-loader.js.map +1 -1
- package/build/model-recipes-model-loader.d.ts +1 -1
- package/build/model-recipes-model-loader.js +129 -207
- package/build/model-recipes-model-loader.js.map +1 -1
- package/build/models-response-reader.js +24 -65
- package/build/models-response-reader.js.map +1 -1
- package/build/models.js +5 -10
- package/build/models.js.map +1 -1
- package/build/money-formatter.d.ts +2 -2
- package/build/money-formatter.d.ts.map +1 -1
- package/build/money-formatter.js +45 -55
- package/build/money-formatter.js.map +1 -1
- package/build/not-loaded-error.js +2 -25
- package/build/not-loaded-error.js.map +1 -1
- package/build/params.js +31 -41
- package/build/params.js.map +1 -1
- package/build/preloaded.js +18 -58
- package/build/preloaded.js.map +1 -1
- package/build/resize-observer.js +5 -11
- package/build/resize-observer.js.map +1 -1
- package/build/rest-props-validator.js +4 -6
- package/build/rest-props-validator.js.map +1 -1
- package/build/result.js +10 -14
- package/build/result.js.map +1 -1
- package/build/router/route.js +178 -311
- package/build/router/route.js.map +1 -1
- package/build/router/switch.js +55 -129
- package/build/router/switch.js.map +1 -1
- package/build/router.js +33 -93
- package/build/router.js.map +1 -1
- package/build/routes-native.js +63 -147
- package/build/routes-native.js.map +1 -1
- package/build/routes.js +25 -79
- package/build/routes.js.map +1 -1
- package/build/run-last.js +19 -24
- package/build/run-last.js.map +1 -1
- package/build/serializer.js +28 -33
- package/build/serializer.js.map +1 -1
- package/build/services.js +9 -18
- package/build/services.js.map +1 -1
- package/build/session-status-updater.js +84 -183
- package/build/session-status-updater.js.map +1 -1
- package/build/source-maps-loader.d.ts +37 -0
- package/build/source-maps-loader.d.ts.map +1 -0
- package/build/source-maps-loader.js +102 -224
- package/build/source-maps-loader.js.map +1 -1
- package/build/super-admin/config-reader.d.ts +2 -2
- package/build/super-admin/config-reader.js +41 -82
- package/build/super-admin/config-reader.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-checkbox.js +52 -114
- package/build/super-admin/edit-page/edit-attribute-checkbox.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-content.js +46 -76
- package/build/super-admin/edit-page/edit-attribute-content.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-input.js +56 -118
- package/build/super-admin/edit-page/edit-attribute-input.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute.js +39 -103
- package/build/super-admin/edit-page/edit-attribute.js.map +1 -1
- package/build/super-admin/edit-page.js +87 -200
- package/build/super-admin/edit-page.js.map +1 -1
- package/build/super-admin/has-edit-config.js +6 -12
- package/build/super-admin/has-edit-config.js.map +1 -1
- package/build/super-admin/index-page.js +16 -43
- package/build/super-admin/index-page.js.map +1 -1
- package/build/super-admin/index.js +86 -209
- package/build/super-admin/index.js.map +1 -1
- package/build/super-admin/layout/header/index.js +90 -151
- package/build/super-admin/layout/header/index.js.map +1 -1
- package/build/super-admin/layout/index.js +69 -152
- package/build/super-admin/layout/index.js.map +1 -1
- package/build/super-admin/layout/menu/index.js +84 -160
- package/build/super-admin/layout/menu/index.js.map +1 -1
- package/build/super-admin/layout/menu/menu-content.js +24 -84
- package/build/super-admin/layout/menu/menu-content.js.map +1 -1
- package/build/super-admin/layout/menu/menu-item.js +51 -101
- package/build/super-admin/layout/menu/menu-item.js.map +1 -1
- package/build/super-admin/layout/no-access.js +18 -44
- package/build/super-admin/layout/no-access.js.map +1 -1
- package/build/super-admin/model-class-table.js +44 -128
- package/build/super-admin/model-class-table.js.map +1 -1
- package/build/super-admin/models.js +5 -41
- package/build/super-admin/models.js.map +1 -1
- package/build/super-admin/show-nav.js +26 -88
- package/build/super-admin/show-nav.js.map +1 -1
- package/build/super-admin/show-page/belongs-to-attribute-row.js +17 -75
- package/build/super-admin/show-page/belongs-to-attribute-row.js.map +1 -1
- package/build/super-admin/show-page/index.js +100 -186
- package/build/super-admin/show-page/index.js.map +1 -1
- package/build/super-admin/show-reflection-actions.js +38 -99
- package/build/super-admin/show-reflection-actions.js.map +1 -1
- package/build/super-admin/show-reflection-link.js +26 -98
- package/build/super-admin/show-reflection-link.js.map +1 -1
- package/build/super-admin/show-reflection-page.js +33 -96
- package/build/super-admin/show-reflection-page.js.map +1 -1
- package/build/table/column-content.js +76 -120
- package/build/table/column-content.js.map +1 -1
- package/build/table/column-identifier.js +6 -10
- package/build/table/column-identifier.js.map +1 -1
- package/build/table/column-visible.js +1 -4
- package/build/table/column-visible.js.map +1 -1
- package/build/table/components/column.js +12 -59
- package/build/table/components/column.js.map +1 -1
- package/build/table/components/flat-list.js +12 -59
- package/build/table/components/flat-list.js.map +1 -1
- package/build/table/components/header.js +14 -61
- package/build/table/components/header.js.map +1 -1
- package/build/table/components/row.js +15 -62
- package/build/table/components/row.js.map +1 -1
- package/build/table/filters/attribute-element.js +33 -61
- package/build/table/filters/attribute-element.js.map +1 -1
- package/build/table/filters/filter-form.js +279 -482
- package/build/table/filters/filter-form.js.map +1 -1
- package/build/table/filters/filter.js +44 -72
- package/build/table/filters/filter.js.map +1 -1
- package/build/table/filters/index.js +94 -138
- package/build/table/filters/index.js.map +1 -1
- package/build/table/filters/load-search-modal.js +63 -211
- package/build/table/filters/load-search-modal.js.map +1 -1
- package/build/table/filters/reflection-element.js +26 -54
- package/build/table/filters/reflection-element.js.map +1 -1
- package/build/table/filters/save-search-modal.js +43 -139
- package/build/table/filters/save-search-modal.js.map +1 -1
- package/build/table/filters/scope-element.js +27 -55
- package/build/table/filters/scope-element.js.map +1 -1
- package/build/table/header-column-content.js +32 -70
- package/build/table/header-column-content.js.map +1 -1
- package/build/table/header-column.js +88 -217
- package/build/table/header-column.js.map +1 -1
- package/build/table/header-select.js +44 -76
- package/build/table/header-select.js.map +1 -1
- package/build/table/model-callback-args.js +4 -40
- package/build/table/model-callback-args.js.map +1 -1
- package/build/table/model-column.js +58 -143
- package/build/table/model-column.js.map +1 -1
- package/build/table/model-row.js +74 -186
- package/build/table/model-row.js.map +1 -1
- package/build/table/select-calculator.js +26 -85
- package/build/table/select-calculator.js.map +1 -1
- package/build/table/settings/column-row.js +65 -185
- package/build/table/settings/column-row.js.map +1 -1
- package/build/table/settings/download-action.js +37 -73
- package/build/table/settings/download-action.js.map +1 -1
- package/build/table/settings/index.js +37 -101
- package/build/table/settings/index.js.map +1 -1
- package/build/table/table-settings.js +184 -322
- package/build/table/table-settings.js.map +1 -1
- package/build/table/table.js +582 -780
- package/build/table/table.js.map +1 -1
- package/build/table/use-sorting.js +15 -34
- package/build/table/use-sorting.js.map +1 -1
- package/build/table/widths.js +31 -37
- package/build/table/widths.js.map +1 -1
- package/build/table/worker-plugins-check-all-checkbox.js +76 -224
- package/build/table/worker-plugins-check-all-checkbox.js.map +1 -1
- package/build/table/worker-plugins-checkbox.js +73 -184
- package/build/table/worker-plugins-checkbox.js.map +1 -1
- package/build/translated-attributes.js +5 -10
- package/build/translated-attributes.js.map +1 -1
- package/build/translated-collections.js +10 -19
- package/build/translated-collections.js.map +1 -1
- package/build/updated-attribute.js +46 -119
- package/build/updated-attribute.js.map +1 -1
- package/build/url-encode.js +5 -11
- package/build/url-encode.js.map +1 -1
- package/build/use-breakpoint.js +42 -94
- package/build/use-breakpoint.js.map +1 -1
- package/build/use-can-can.js +29 -91
- package/build/use-can-can.js.map +1 -1
- package/build/use-collection.js +118 -228
- package/build/use-collection.js.map +1 -1
- package/build/use-created-event.js +26 -43
- package/build/use-created-event.js.map +1 -1
- package/build/use-current-user-context.js +56 -150
- package/build/use-current-user-context.js.map +1 -1
- package/build/use-current-user.js +13 -31
- package/build/use-current-user.js.map +1 -1
- package/build/use-destroyed-event.js +21 -42
- package/build/use-destroyed-event.js.map +1 -1
- package/build/use-event-emitter.js +9 -14
- package/build/use-event-emitter.js.map +1 -1
- package/build/use-event-listener.js +12 -21
- package/build/use-event-listener.js.map +1 -1
- package/build/use-input.js +48 -68
- package/build/use-input.js.map +1 -1
- package/build/use-model-event.js +21 -42
- package/build/use-model-event.js.map +1 -1
- package/build/use-model.js +95 -198
- package/build/use-model.js.map +1 -1
- package/build/use-resize-observer.js +10 -20
- package/build/use-resize-observer.js.map +1 -1
- package/build/use-router.js +64 -106
- package/build/use-router.js.map +1 -1
- package/build/use-screen-layout.js +16 -18
- package/build/use-screen-layout.js.map +1 -1
- package/build/use-styles.js +23 -74
- package/build/use-styles.js.map +1 -1
- package/build/use-updated-event.js +21 -43
- package/build/use-updated-event.js.map +1 -1
- package/build/use-validation-errors.js +11 -17
- package/build/use-validation-errors.js.map +1 -1
- package/build/utils/button.js +85 -135
- package/build/utils/button.js.map +1 -1
- package/build/utils/card.js +30 -105
- package/build/utils/card.js.map +1 -1
- package/build/utils/checkbox.js +50 -111
- package/build/utils/checkbox.js.map +1 -1
- package/build/utils/checkboxes.js +108 -181
- package/build/utils/checkboxes.js.map +1 -1
- package/build/utils/default-style.js +28 -102
- package/build/utils/default-style.js.map +1 -1
- package/build/utils/header.js +7 -34
- package/build/utils/header.js.map +1 -1
- package/build/utils/icon.js +35 -116
- package/build/utils/icon.js.map +1 -1
- package/build/utils/invalid-feedback.js +15 -42
- package/build/utils/invalid-feedback.js.map +1 -1
- package/build/utils/modal.js +24 -107
- package/build/utils/modal.js.map +1 -1
- package/build/utils/text.js +9 -36
- package/build/utils/text.js.map +1 -1
- package/build/validation-error.js +30 -88
- package/build/validation-error.js.map +1 -1
- package/build/validation-errors.js +60 -110
- package/build/validation-errors.js.map +1 -1
- package/build/with-api-maker.js +14 -66
- package/build/with-api-maker.js.map +1 -1
- package/build/with-collection.js +13 -63
- package/build/with-collection.js.map +1 -1
- package/build/with-current-user.js +6 -22
- package/build/with-current-user.js.map +1 -1
- package/build/with-model.js +10 -26
- package/build/with-model.js.map +1 -1
- package/build/with-router.js +7 -34
- package/build/with-router.js.map +1 -1
- package/package.json +1 -1
package/build/collection.js
CHANGED
|
@@ -1,85 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
72
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
73
|
-
};
|
|
74
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
-
var clone_deep_1 = __importDefault(require("clone-deep"));
|
|
76
|
-
var commands_pool_js_1 = __importDefault(require("./commands-pool.js"));
|
|
77
|
-
var diggerize_1 = require("diggerize");
|
|
78
|
-
var inflection = __importStar(require("inflection"));
|
|
79
|
-
var incorporator_1 = require("incorporator");
|
|
80
|
-
var model_class_require_js_1 = __importDefault(require("./model-class-require.js"));
|
|
81
|
-
var result_js_1 = __importDefault(require("./result.js"));
|
|
82
|
-
var uniqunize_1 = __importDefault(require("uniqunize"));
|
|
1
|
+
import cloneDeep from "clone-deep";
|
|
2
|
+
import CommandsPool from "./commands-pool.js";
|
|
3
|
+
import { digg } from "diggerize";
|
|
4
|
+
import * as inflection from "inflection";
|
|
5
|
+
import { incorporate } from "incorporator";
|
|
6
|
+
import modelClassRequire from "./model-class-require.js";
|
|
7
|
+
import Result from "./result.js";
|
|
8
|
+
import uniqunize from "uniqunize";
|
|
83
9
|
/**
|
|
84
10
|
* @template {typeof import("./base-model.js").default} MC
|
|
85
11
|
* @typedef {InstanceType<MC>} ModelOf
|
|
@@ -111,124 +37,86 @@ var uniqunize_1 = __importDefault(require("uniqunize"));
|
|
|
111
37
|
/**
|
|
112
38
|
* @template {typeof import("./base-model.js").default} MC
|
|
113
39
|
*/
|
|
114
|
-
|
|
40
|
+
export default class ApiMakerCollection {
|
|
41
|
+
static apiMakerType = "Collection";
|
|
115
42
|
/**
|
|
116
43
|
* @param {CollectionArgsType<MC>} args
|
|
117
44
|
* @param {QueryArgsType} queryArgs
|
|
118
45
|
*/
|
|
119
|
-
|
|
120
|
-
if (queryArgs === void 0) { queryArgs = {}; }
|
|
46
|
+
constructor(args, queryArgs = {}) {
|
|
121
47
|
if (!args.modelClass)
|
|
122
|
-
throw new Error(
|
|
48
|
+
throw new Error(`No modelClass given in ${Object.keys(args).join(", ")}`);
|
|
123
49
|
this.queryArgs = queryArgs;
|
|
124
50
|
this.args = args;
|
|
125
51
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
for (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
for (
|
|
133
|
-
|
|
134
|
-
var newAbilityName = inflection.underscore(originalAbilityName_1);
|
|
52
|
+
abilities(originalAbilities) {
|
|
53
|
+
const newAbilities = {};
|
|
54
|
+
for (const originalAbilityName in originalAbilities) {
|
|
55
|
+
const newModelName = inflection.underscore(originalAbilityName);
|
|
56
|
+
const newValues = [];
|
|
57
|
+
const originalValues = originalAbilities[originalAbilityName];
|
|
58
|
+
for (const originalAbilityName of originalValues) {
|
|
59
|
+
const newAbilityName = inflection.underscore(originalAbilityName);
|
|
135
60
|
newValues.push(newAbilityName);
|
|
136
61
|
}
|
|
137
62
|
newAbilities[newModelName] = newValues;
|
|
138
63
|
}
|
|
139
64
|
return this._merge({ abilities: newAbilities });
|
|
140
|
-
}
|
|
65
|
+
}
|
|
141
66
|
/**
|
|
142
67
|
* @param {string} abilityName
|
|
143
68
|
* @returns {this}
|
|
144
69
|
*/
|
|
145
|
-
|
|
70
|
+
accessibleBy(abilityName) {
|
|
146
71
|
return this._merge({ accessibleBy: inflection.underscore(abilityName) });
|
|
147
|
-
}
|
|
72
|
+
}
|
|
148
73
|
/**
|
|
149
74
|
* @returns {Promise<number>}
|
|
150
75
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
switch (_a.label) {
|
|
156
|
-
case 0: return [4 /*yield*/, this.clone()._merge({ count: true })._response()];
|
|
157
|
-
case 1:
|
|
158
|
-
response = _a.sent();
|
|
159
|
-
return [2 /*return*/, (0, diggerize_1.digg)(response, "count")];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
};
|
|
76
|
+
async count() {
|
|
77
|
+
const response = await this.clone()._merge({ count: true })._response();
|
|
78
|
+
return digg(response, "count");
|
|
79
|
+
}
|
|
164
80
|
/**
|
|
165
81
|
* @returns {this}
|
|
166
82
|
*/
|
|
167
|
-
|
|
83
|
+
distinct() {
|
|
168
84
|
return this._merge({ distinct: true });
|
|
169
|
-
}
|
|
85
|
+
}
|
|
170
86
|
/**
|
|
171
87
|
* @param {function(import("./base-model.js").default) : void} callback
|
|
172
88
|
* @returns {Promise<void>}
|
|
173
89
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
case 1:
|
|
181
|
-
array = _a.sent();
|
|
182
|
-
for (model in array) {
|
|
183
|
-
callback.call(model);
|
|
184
|
-
}
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
90
|
+
async each(callback) {
|
|
91
|
+
const array = await this.toArray();
|
|
92
|
+
for (const model in array) {
|
|
93
|
+
callback.call(model);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
190
96
|
/**
|
|
191
97
|
* @param {...string} keys
|
|
192
98
|
* @returns {this}
|
|
193
99
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
197
|
-
keys[_i] = arguments[_i];
|
|
198
|
-
}
|
|
199
|
-
for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
|
|
200
|
-
var key = keys_1[_a];
|
|
100
|
+
except(...keys) {
|
|
101
|
+
for (const key of keys) {
|
|
201
102
|
if (key == "page") {
|
|
202
103
|
delete this.queryArgs[key];
|
|
203
104
|
}
|
|
204
105
|
else {
|
|
205
|
-
throw new Error(
|
|
106
|
+
throw new Error(`Unhandled key: ${key}`);
|
|
206
107
|
}
|
|
207
108
|
}
|
|
208
109
|
return this;
|
|
209
|
-
}
|
|
110
|
+
}
|
|
210
111
|
/**
|
|
211
112
|
* @returns {Promise<ModelOf<MC>>}
|
|
212
113
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
case 1:
|
|
220
|
-
models = _a.sent();
|
|
221
|
-
return [2 /*return*/, models[0]];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
ApiMakerCollection.prototype.groupBy = function () {
|
|
227
|
-
var arrayOfTablesAndColumns = [];
|
|
228
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
229
|
-
arrayOfTablesAndColumns[_i] = arguments[_i];
|
|
230
|
-
}
|
|
231
|
-
var arrayOfTablesAndColumnsWithLowercaseColumns = arrayOfTablesAndColumns.map(function (tableAndColumn) {
|
|
114
|
+
async first() {
|
|
115
|
+
const models = await this.toArray();
|
|
116
|
+
return models[0];
|
|
117
|
+
}
|
|
118
|
+
groupBy(...arrayOfTablesAndColumns) {
|
|
119
|
+
const arrayOfTablesAndColumnsWithLowercaseColumns = arrayOfTablesAndColumns.map((tableAndColumn) => {
|
|
232
120
|
if (Array.isArray(tableAndColumn)) {
|
|
233
121
|
return [tableAndColumn[0], tableAndColumn[1].toLowerCase()];
|
|
234
122
|
}
|
|
@@ -236,34 +124,24 @@ var ApiMakerCollection = /** @class */ (function () {
|
|
|
236
124
|
return tableAndColumn.toLowerCase();
|
|
237
125
|
}
|
|
238
126
|
});
|
|
239
|
-
|
|
240
|
-
|
|
127
|
+
const currentGroupBy = this.queryArgs.groupBy || [];
|
|
128
|
+
const newGroupBy = currentGroupBy.concat(arrayOfTablesAndColumnsWithLowercaseColumns);
|
|
241
129
|
return this._merge({
|
|
242
130
|
groupBy: newGroupBy
|
|
243
131
|
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return [4 /*yield*/, this.toArray()];
|
|
253
|
-
case 1:
|
|
254
|
-
models = _a.sent();
|
|
255
|
-
this.set(models);
|
|
256
|
-
_a.label = 2;
|
|
257
|
-
case 2: return [2 /*return*/, this.loaded()];
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
};
|
|
132
|
+
}
|
|
133
|
+
async ensureLoaded() {
|
|
134
|
+
if (!this.isLoaded()) {
|
|
135
|
+
const models = await this.toArray();
|
|
136
|
+
this.set(models);
|
|
137
|
+
}
|
|
138
|
+
return this.loaded();
|
|
139
|
+
}
|
|
262
140
|
/**
|
|
263
141
|
* @returns {boolean}
|
|
264
142
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
143
|
+
isLoaded() {
|
|
144
|
+
const { model, reflectionName } = this.args;
|
|
267
145
|
if (reflectionName in model.relationshipsCache) {
|
|
268
146
|
return true;
|
|
269
147
|
}
|
|
@@ -271,28 +149,28 @@ var ApiMakerCollection = /** @class */ (function () {
|
|
|
271
149
|
return true;
|
|
272
150
|
}
|
|
273
151
|
return false;
|
|
274
|
-
}
|
|
152
|
+
}
|
|
275
153
|
/**
|
|
276
154
|
* @param {number} amount
|
|
277
155
|
* @returns {this}
|
|
278
156
|
*/
|
|
279
|
-
|
|
157
|
+
limit(amount) {
|
|
280
158
|
return this._merge({ limit: amount });
|
|
281
|
-
}
|
|
159
|
+
}
|
|
282
160
|
/**
|
|
283
161
|
* @returns {Array<ModelOf<MC>>}
|
|
284
162
|
*/
|
|
285
|
-
|
|
163
|
+
preloaded() {
|
|
286
164
|
if (!(this.args.reflectionName in this.args.model.relationshipsCache)) {
|
|
287
|
-
throw new Error(
|
|
165
|
+
throw new Error(`${this.args.reflectionName} hasnt been loaded yet`);
|
|
288
166
|
}
|
|
289
167
|
return this.args.model.relationshipsCache[this.args.reflectionName];
|
|
290
|
-
}
|
|
168
|
+
}
|
|
291
169
|
/**
|
|
292
170
|
* @returns {ModelOf<MC> | Array<ModelOf<MC>>}
|
|
293
171
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
172
|
+
loaded() {
|
|
173
|
+
const { model, reflectionName } = this.args;
|
|
296
174
|
if (reflectionName in model.relationships) {
|
|
297
175
|
return model.relationships[reflectionName];
|
|
298
176
|
}
|
|
@@ -300,84 +178,84 @@ var ApiMakerCollection = /** @class */ (function () {
|
|
|
300
178
|
return model.relationshipsCache[reflectionName];
|
|
301
179
|
}
|
|
302
180
|
else if (model.isNewRecord()) {
|
|
303
|
-
|
|
181
|
+
const reflectionNameUnderscore = inflection.underscore(reflectionName);
|
|
304
182
|
// Initialize as empty and try again to return the empty result
|
|
305
183
|
this.set([]);
|
|
306
|
-
return
|
|
184
|
+
return digg(model.relationships, reflectionNameUnderscore);
|
|
307
185
|
}
|
|
308
186
|
else {
|
|
309
|
-
|
|
310
|
-
throw new Error(
|
|
187
|
+
const relationshipsLoaded = uniqunize(Object.keys(model.relationships).concat(Object.keys(model.relationshipsCache)));
|
|
188
|
+
throw new Error(`${reflectionName} hasnt been loaded yet on ${model.modelClassData().name}. Loaded was: ${relationshipsLoaded.join(", ")}`);
|
|
311
189
|
}
|
|
312
|
-
}
|
|
190
|
+
}
|
|
313
191
|
/** @returns {Array<ModelOf<MC>>} */
|
|
314
|
-
|
|
315
|
-
|
|
192
|
+
loadedArray() {
|
|
193
|
+
const loaded = this.loaded();
|
|
316
194
|
if (Array.isArray(loaded)) {
|
|
317
195
|
return loaded;
|
|
318
196
|
}
|
|
319
197
|
else {
|
|
320
198
|
throw new Error("'loaded' wasn't an array");
|
|
321
199
|
}
|
|
322
|
-
}
|
|
200
|
+
}
|
|
323
201
|
// Replaces the relationships with the given new collection.
|
|
324
|
-
|
|
202
|
+
set(newCollection) {
|
|
325
203
|
this.args.model.relationships[this.args.reflectionName] = newCollection;
|
|
326
|
-
}
|
|
204
|
+
}
|
|
327
205
|
// Pushes another model onto the given collection.
|
|
328
|
-
|
|
329
|
-
|
|
206
|
+
push(newModel) {
|
|
207
|
+
const { model, reflectionName } = this.args;
|
|
330
208
|
if (!(reflectionName in model.relationships)) {
|
|
331
209
|
model.relationships[reflectionName] = [];
|
|
332
210
|
}
|
|
333
211
|
if (!model.relationships[reflectionName].includes(newModel)) {
|
|
334
212
|
model.relationships[reflectionName].push(newModel);
|
|
335
213
|
}
|
|
336
|
-
}
|
|
214
|
+
}
|
|
337
215
|
// Array shortcuts
|
|
338
216
|
/**
|
|
339
217
|
* @param {function(import("./base-model.js").default): boolean} callback
|
|
340
218
|
* @returns {import("./base-model.js").default}
|
|
341
219
|
*/
|
|
342
|
-
|
|
220
|
+
find(callback) { return this.loadedArray().find(callback); }
|
|
343
221
|
/**
|
|
344
222
|
* @param {function(import("./base-model.js").default): void} callback
|
|
345
223
|
* @returns {void}
|
|
346
224
|
*/
|
|
347
|
-
|
|
225
|
+
forEach(callback) { return this.loadedArray().forEach(callback); }
|
|
348
226
|
/**
|
|
349
227
|
* @param {function(import("./base-model.js").default): void} callback
|
|
350
228
|
* @returns {any[]}
|
|
351
229
|
*/
|
|
352
|
-
|
|
230
|
+
map(callback) { return this.loadedArray().map(callback); }
|
|
353
231
|
/**
|
|
354
232
|
* @param {string[]} preloadValue
|
|
355
233
|
* @returns {this}
|
|
356
234
|
*/
|
|
357
|
-
|
|
235
|
+
preload(preloadValue) {
|
|
358
236
|
return this._merge({ preload: preloadValue });
|
|
359
|
-
}
|
|
237
|
+
}
|
|
360
238
|
/**
|
|
361
239
|
* @param {number} page
|
|
362
240
|
* @returns {this}
|
|
363
241
|
*/
|
|
364
|
-
|
|
242
|
+
page(page) {
|
|
365
243
|
if (!page)
|
|
366
244
|
page = 1;
|
|
367
|
-
return this._merge({ page
|
|
368
|
-
}
|
|
245
|
+
return this._merge({ page });
|
|
246
|
+
}
|
|
369
247
|
/**
|
|
370
248
|
* @param {string} pageKey
|
|
371
249
|
* @returns {this}
|
|
372
250
|
*/
|
|
373
|
-
|
|
374
|
-
return this._merge({ pageKey
|
|
375
|
-
}
|
|
251
|
+
pageKey(pageKey) {
|
|
252
|
+
return this._merge({ pageKey });
|
|
253
|
+
}
|
|
376
254
|
/**
|
|
377
255
|
* @returns {boolean}
|
|
378
256
|
*/
|
|
379
|
-
|
|
380
|
-
|
|
257
|
+
isFiltered() {
|
|
258
|
+
const { queryArgs } = this;
|
|
381
259
|
if (queryArgs.accessibleBy ||
|
|
382
260
|
queryArgs.count ||
|
|
383
261
|
queryArgs.limit ||
|
|
@@ -389,14 +267,14 @@ var ApiMakerCollection = /** @class */ (function () {
|
|
|
389
267
|
return true;
|
|
390
268
|
}
|
|
391
269
|
return false;
|
|
392
|
-
}
|
|
270
|
+
}
|
|
393
271
|
/**
|
|
394
272
|
* @returns {Record<string, any>}
|
|
395
273
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
274
|
+
params() {
|
|
275
|
+
let params = {};
|
|
398
276
|
if (this.queryArgs.params)
|
|
399
|
-
params =
|
|
277
|
+
params = incorporate(params, this.queryArgs.params);
|
|
400
278
|
if (this.queryArgs.abilities)
|
|
401
279
|
params.abilities = this.queryArgs.abilities;
|
|
402
280
|
if (this.queryArgs.accessibleBy)
|
|
@@ -424,173 +302,148 @@ var ApiMakerCollection = /** @class */ (function () {
|
|
|
424
302
|
if (this.queryArgs.selectColumns)
|
|
425
303
|
params.select_columns = this.queryArgs.selectColumns;
|
|
426
304
|
return params;
|
|
427
|
-
}
|
|
305
|
+
}
|
|
428
306
|
/**
|
|
429
307
|
* @param {number} per
|
|
430
308
|
* @returns {this}
|
|
431
309
|
*/
|
|
432
|
-
|
|
433
|
-
return this._merge({ per
|
|
434
|
-
}
|
|
310
|
+
per(per) {
|
|
311
|
+
return this._merge({ per });
|
|
312
|
+
}
|
|
435
313
|
/**
|
|
436
314
|
* @param {string} perKey
|
|
437
315
|
* @returns {this}
|
|
438
316
|
*/
|
|
439
|
-
|
|
440
|
-
return this._merge({ perKey
|
|
441
|
-
}
|
|
317
|
+
perKey(perKey) {
|
|
318
|
+
return this._merge({ perKey });
|
|
319
|
+
}
|
|
442
320
|
/**
|
|
443
321
|
* @param {Record<string, any>} params
|
|
444
322
|
* @returns {this}
|
|
445
323
|
*/
|
|
446
|
-
|
|
324
|
+
ransack(params) {
|
|
447
325
|
if (params)
|
|
448
326
|
this._merge({ ransack: params });
|
|
449
327
|
return this;
|
|
450
|
-
}
|
|
328
|
+
}
|
|
451
329
|
/**
|
|
452
330
|
* @returns {Promise<Result>}
|
|
453
331
|
*/
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
response = _a.sent();
|
|
462
|
-
models = (0, diggerize_1.digg)(response, "collection");
|
|
463
|
-
this._addQueryToModels(models);
|
|
464
|
-
result = new result_js_1.default({ collection: this, models: models, response: response });
|
|
465
|
-
return [2 /*return*/, result];
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
};
|
|
332
|
+
async result() {
|
|
333
|
+
const response = await this._response();
|
|
334
|
+
const models = digg(response, "collection");
|
|
335
|
+
this._addQueryToModels(models);
|
|
336
|
+
const result = new Result({ collection: this, models, response });
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
470
339
|
/**
|
|
471
340
|
* @param {Record<string, any>} params
|
|
472
341
|
* @returns {this}
|
|
473
342
|
*/
|
|
474
|
-
|
|
343
|
+
search(params) {
|
|
475
344
|
if (params)
|
|
476
345
|
this._merge({ search: params });
|
|
477
346
|
return this;
|
|
478
|
-
}
|
|
347
|
+
}
|
|
479
348
|
/**
|
|
480
349
|
* @param {string} searchKey
|
|
481
350
|
* @returns {this}
|
|
482
351
|
*/
|
|
483
|
-
|
|
484
|
-
return this._merge({ searchKey
|
|
485
|
-
}
|
|
352
|
+
searchKey(searchKey) {
|
|
353
|
+
return this._merge({ searchKey });
|
|
354
|
+
}
|
|
486
355
|
/**
|
|
487
356
|
* @param {Record<string, string[]>} originalSelect
|
|
488
357
|
* @returns {this}
|
|
489
358
|
*/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
for (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
for (
|
|
497
|
-
|
|
498
|
-
var newAttributeName = inflection.underscore(originalAttributeName);
|
|
359
|
+
select(originalSelect) {
|
|
360
|
+
const newSelect = {};
|
|
361
|
+
for (const originalModelName in originalSelect) {
|
|
362
|
+
const newModelName = inflection.underscore(originalModelName);
|
|
363
|
+
const newValues = [];
|
|
364
|
+
const originalValues = originalSelect[originalModelName];
|
|
365
|
+
for (const originalAttributeName of originalValues) {
|
|
366
|
+
const newAttributeName = inflection.underscore(originalAttributeName);
|
|
499
367
|
newValues.push(newAttributeName);
|
|
500
368
|
}
|
|
501
369
|
newSelect[newModelName] = newValues;
|
|
502
370
|
}
|
|
503
371
|
return this._merge({ select: newSelect });
|
|
504
|
-
}
|
|
372
|
+
}
|
|
505
373
|
/**
|
|
506
374
|
* @param {Record<string, string[]>} originalSelect
|
|
507
375
|
* @returns {this}
|
|
508
376
|
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
for (
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
for (
|
|
516
|
-
|
|
517
|
-
var newAttributeName = inflection.underscore(originalAttributeName);
|
|
377
|
+
selectColumns(originalSelect) {
|
|
378
|
+
const newSelect = {};
|
|
379
|
+
for (const originalModelName in originalSelect) {
|
|
380
|
+
const newModelName = inflection.underscore(inflection.underscore(originalModelName));
|
|
381
|
+
const newValues = [];
|
|
382
|
+
const originalValues = originalSelect[originalModelName];
|
|
383
|
+
for (const originalAttributeName of originalValues) {
|
|
384
|
+
const newAttributeName = inflection.underscore(originalAttributeName);
|
|
518
385
|
newValues.push(newAttributeName);
|
|
519
386
|
}
|
|
520
387
|
newSelect[newModelName] = newValues;
|
|
521
388
|
}
|
|
522
389
|
return this._merge({ selectColumns: newSelect });
|
|
523
|
-
}
|
|
390
|
+
}
|
|
524
391
|
/**
|
|
525
392
|
* @param {string} sortBy
|
|
526
393
|
* @returns {this}
|
|
527
394
|
*/
|
|
528
|
-
|
|
395
|
+
sort(sortBy) {
|
|
529
396
|
return this._merge({ ransack: { s: sortBy } });
|
|
530
|
-
}
|
|
397
|
+
}
|
|
531
398
|
/**
|
|
532
399
|
* @returns {Promise<Array<ModelOf<MC>>>}
|
|
533
400
|
*/
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
case 1:
|
|
541
|
-
response = _a.sent();
|
|
542
|
-
models = (0, diggerize_1.digg)(response, "collection");
|
|
543
|
-
this._addQueryToModels(models);
|
|
544
|
-
return [2 /*return*/, models];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
};
|
|
401
|
+
async toArray() {
|
|
402
|
+
const response = await this._response();
|
|
403
|
+
const models = digg(response, "collection");
|
|
404
|
+
this._addQueryToModels(models);
|
|
405
|
+
return models;
|
|
406
|
+
}
|
|
549
407
|
/**
|
|
550
408
|
* @returns {MC}
|
|
551
409
|
*/
|
|
552
|
-
|
|
410
|
+
modelClass() {
|
|
553
411
|
if (!this.args.modelClass) {
|
|
554
412
|
throw new Error("No model class given in args");
|
|
555
413
|
}
|
|
556
414
|
return this.args.modelClass;
|
|
557
|
-
}
|
|
415
|
+
}
|
|
558
416
|
/**
|
|
559
417
|
* @returns {ApiMakerCollection}
|
|
560
418
|
*/
|
|
561
|
-
|
|
562
|
-
|
|
419
|
+
clone() {
|
|
420
|
+
const clonedQueryArgs = cloneDeep(this.queryArgs);
|
|
563
421
|
return new ApiMakerCollection(this.args, clonedQueryArgs);
|
|
564
|
-
}
|
|
422
|
+
}
|
|
565
423
|
// This is needed when reloading a version of the model with the same selected attributes and preloads
|
|
566
|
-
|
|
567
|
-
for (
|
|
568
|
-
var model = models_1[_i];
|
|
424
|
+
_addQueryToModels(models) {
|
|
425
|
+
for (const model of models) {
|
|
569
426
|
model.collection = this;
|
|
570
427
|
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
428
|
+
}
|
|
429
|
+
_merge(newQueryArgs) {
|
|
430
|
+
incorporate(this.queryArgs, newQueryArgs);
|
|
574
431
|
return this;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
var _a;
|
|
432
|
+
}
|
|
433
|
+
_response() {
|
|
578
434
|
if (!this.args)
|
|
579
435
|
throw new Error("No args?");
|
|
580
436
|
if (!this.args.modelClass)
|
|
581
437
|
throw new Error("No modelClass in args");
|
|
582
438
|
if (!this.args.modelClass.modelClassData)
|
|
583
|
-
throw new Error(
|
|
584
|
-
|
|
585
|
-
return
|
|
439
|
+
throw new Error(`No modelClassData on modelClass ${this.args.modelClass?.name} (${typeof this.args.modelClass})`);
|
|
440
|
+
const modelClassData = this.args.modelClass.modelClassData();
|
|
441
|
+
return CommandsPool.addCommand({
|
|
586
442
|
args: this.params(),
|
|
587
|
-
command:
|
|
443
|
+
command: `${modelClassData.collectionName}-index`,
|
|
588
444
|
collectionName: modelClassData.collectionName,
|
|
589
445
|
type: "index"
|
|
590
446
|
}, {});
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
return ApiMakerCollection;
|
|
594
|
-
}());
|
|
595
|
-
exports.default = ApiMakerCollection;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
596
449
|
//# sourceMappingURL=collection.js.map
|