@livepreso/api 6.40.0 → 6.43.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/.eslintrc.js +5 -0
- package/.rush/temp/build-cache-tar.log +7 -0
- package/.rush/temp/package-deps_build.json +170 -0
- package/.rush/temp/shrinkwrap-deps.json +846 -0
- package/CHANGELOG.json +41 -0
- package/CHANGELOG.md +25 -0
- package/api.build.log +15 -0
- package/babel.config.js +9 -18
- package/cjs/api.js +1 -1
- package/cjs/api.js.map +1 -1
- package/cjs/api.spec.js +2 -2
- package/cjs/api.spec.js.map +1 -1
- package/cjs/auth.js +6 -5
- package/cjs/auth.js.map +1 -1
- package/cjs/auth.spec.js +25 -23
- package/cjs/auth.spec.js.map +1 -1
- package/cjs/caching.js +3 -3
- package/cjs/collections/activity.js +22 -27
- package/cjs/collections/activity.js.map +1 -1
- package/cjs/collections/adjunct-sections.js +2 -2
- package/cjs/collections/adjunct-sections.js.map +1 -1
- package/cjs/collections/adjunct-slides.js +2 -2
- package/cjs/collections/adjunct-slides.js.map +1 -1
- package/cjs/collections/adjunct-sub-slides.js +2 -2
- package/cjs/collections/adjunct-sub-slides.js.map +1 -1
- package/cjs/collections/appointment-adjunct-tags.js +28 -0
- package/cjs/collections/appointment-adjunct-tags.js.map +1 -0
- package/cjs/collections/appointment-deckversion-tags.js +28 -0
- package/cjs/collections/appointment-deckversion-tags.js.map +1 -0
- package/cjs/collections/appointment-duplicates.js +2 -2
- package/cjs/collections/appointment-duplicates.js.map +1 -1
- package/cjs/collections/appointment-editors.js +2 -2
- package/cjs/collections/appointment-editors.js.map +1 -1
- package/cjs/collections/appointment-section-tags.js +28 -0
- package/cjs/collections/appointment-section-tags.js.map +1 -0
- package/cjs/collections/appointment-slide-tags.js +28 -0
- package/cjs/collections/appointment-slide-tags.js.map +1 -0
- package/cjs/collections/appointment-tags.js +208 -0
- package/cjs/collections/appointment-tags.js.map +1 -0
- package/cjs/collections/appointments.js +10 -6
- package/cjs/collections/appointments.js.map +1 -1
- package/cjs/collections/assets.js +2 -2
- package/cjs/collections/assets.js.map +1 -1
- package/cjs/collections/auto-adjuncts.js +7 -3
- package/cjs/collections/auto-adjuncts.js.map +1 -1
- package/cjs/collections/base.js +30 -25
- package/cjs/collections/base.js.map +1 -1
- package/cjs/collections/base.spec.js +71 -123
- package/cjs/collections/base.spec.js.map +1 -1
- package/cjs/collections/cms-vals.js +2 -2
- package/cjs/collections/cms-vals.js.map +1 -1
- package/cjs/collections/contacts.js +2 -2
- package/cjs/collections/contacts.js.map +1 -1
- package/cjs/collections/created-assets.js +2 -2
- package/cjs/collections/created-assets.js.map +1 -1
- package/cjs/collections/customers.js +2 -2
- package/cjs/collections/customers.js.map +1 -1
- package/cjs/collections/deck-notes.js +2 -2
- package/cjs/collections/deck-notes.js.map +1 -1
- package/cjs/collections/deck-versions.js +20 -8
- package/cjs/collections/deck-versions.js.map +1 -1
- package/cjs/collections/decks.js +2 -2
- package/cjs/collections/decks.js.map +1 -1
- package/cjs/collections/deleted-assets.js +2 -2
- package/cjs/collections/deleted-assets.js.map +1 -1
- package/cjs/collections/dispatches.js +4 -4
- package/cjs/collections/dispatches.js.map +1 -1
- package/cjs/collections/event-objects.js +2 -2
- package/cjs/collections/event-objects.js.map +1 -1
- package/cjs/collections/events.js +2 -2
- package/cjs/collections/events.js.map +1 -1
- package/cjs/collections/groups.js +2 -2
- package/cjs/collections/groups.js.map +1 -1
- package/cjs/collections/images.js +2 -2
- package/cjs/collections/images.js.map +1 -1
- package/cjs/collections/locations.js +2 -2
- package/cjs/collections/locations.js.map +1 -1
- package/cjs/collections/opportunities.js +2 -2
- package/cjs/collections/opportunities.js.map +1 -1
- package/cjs/collections/pack-diffs.js +2 -2
- package/cjs/collections/pack-diffs.js.map +1 -1
- package/cjs/collections/packs.js +2 -2
- package/cjs/collections/packs.js.map +1 -1
- package/cjs/collections/presets.js +2 -2
- package/cjs/collections/presets.js.map +1 -1
- package/cjs/collections/section-selections.js +2 -2
- package/cjs/collections/section-selections.js.map +1 -1
- package/cjs/collections/sections.js +2 -2
- package/cjs/collections/sections.js.map +1 -1
- package/cjs/collections/slide-selections.js +2 -2
- package/cjs/collections/slide-selections.js.map +1 -1
- package/cjs/collections/slides.js +2 -2
- package/cjs/collections/slides.js.map +1 -1
- package/cjs/collections/snapshots.js +2 -2
- package/cjs/collections/snapshots.js.map +1 -1
- package/cjs/collections/sub-slides.js +2 -2
- package/cjs/collections/sub-slides.js.map +1 -1
- package/cjs/collections/tags.js +28 -0
- package/cjs/collections/tags.js.map +1 -0
- package/cjs/collections/teams.js +2 -2
- package/cjs/collections/teams.js.map +1 -1
- package/cjs/collections/templates.js +2 -2
- package/cjs/collections/templates.js.map +1 -1
- package/cjs/collections/uploads.js +2 -2
- package/cjs/collections/uploads.js.map +1 -1
- package/cjs/collections/users.js +2 -2
- package/cjs/collections/users.js.map +1 -1
- package/cjs/collections.js +115 -0
- package/cjs/collections.js.map +1 -1
- package/cjs/index.js +3 -0
- package/cjs/index.js.map +1 -1
- package/cjs/middleware.js.map +1 -1
- package/cjs/middlewares/auth.js +10 -6
- package/cjs/middlewares/auth.js.map +1 -1
- package/cjs/middlewares/base.js +1 -3
- package/cjs/middlewares/base.js.map +1 -1
- package/cjs/middlewares/json.js +10 -6
- package/cjs/middlewares/json.js.map +1 -1
- package/cjs/middlewares/redirect.js +10 -6
- package/cjs/middlewares/redirect.js.map +1 -1
- package/cjs/models/activity-item.js +6 -2
- package/cjs/models/activity-item.js.map +1 -1
- package/cjs/models/adjunct-section.js +2 -2
- package/cjs/models/adjunct-section.js.map +1 -1
- package/cjs/models/adjunct-slide.js +2 -2
- package/cjs/models/adjunct-slide.js.map +1 -1
- package/cjs/models/adjunct-sub-slide.js +2 -2
- package/cjs/models/adjunct-sub-slide.js.map +1 -1
- package/cjs/models/adjunct.js +2 -2
- package/cjs/models/adjunct.js.map +1 -1
- package/cjs/models/api.js.map +1 -1
- package/cjs/models/appointment-adjunct-tags.js +52 -0
- package/cjs/models/appointment-adjunct-tags.js.map +1 -0
- package/cjs/models/appointment-deckversion-tags.js +52 -0
- package/cjs/models/appointment-deckversion-tags.js.map +1 -0
- package/cjs/models/appointment-duplicate.js +8 -3
- package/cjs/models/appointment-duplicate.js.map +1 -1
- package/cjs/models/appointment-editor.js +2 -2
- package/cjs/models/appointment-editor.js.map +1 -1
- package/cjs/models/appointment-section-tags.js +52 -0
- package/cjs/models/appointment-section-tags.js.map +1 -0
- package/cjs/models/appointment-slide-tags.js +52 -0
- package/cjs/models/appointment-slide-tags.js.map +1 -0
- package/cjs/models/appointment-stats.js +2 -2
- package/cjs/models/appointment-stats.js.map +1 -1
- package/cjs/models/appointment-tags.js +48 -0
- package/cjs/models/appointment-tags.js.map +1 -0
- package/cjs/models/appointment-viewing.js +2 -2
- package/cjs/models/appointment-viewing.js.map +1 -1
- package/cjs/models/appointment.js +16 -7
- package/cjs/models/appointment.js.map +1 -1
- package/cjs/models/asset.js +2 -2
- package/cjs/models/asset.js.map +1 -1
- package/cjs/models/auto-adjunct-key-check.js +2 -2
- package/cjs/models/auto-adjunct-key-check.js.map +1 -1
- package/cjs/models/auto-adjunct.js +2 -2
- package/cjs/models/auto-adjunct.js.map +1 -1
- package/cjs/models/base.js +25 -36
- package/cjs/models/base.js.map +1 -1
- package/cjs/models/base.spec.js +45 -45
- package/cjs/models/base.spec.js.map +1 -1
- package/cjs/models/choicelist.js.map +1 -1
- package/cjs/models/cms-val.js.map +1 -1
- package/cjs/models/contact.js +2 -2
- package/cjs/models/contact.js.map +1 -1
- package/cjs/models/customer.js +2 -2
- package/cjs/models/customer.js.map +1 -1
- package/cjs/models/deck-note.js +2 -2
- package/cjs/models/deck-note.js.map +1 -1
- package/cjs/models/deck-tags.js +61 -0
- package/cjs/models/deck-tags.js.map +1 -0
- package/cjs/models/deck-version.js +5 -3
- package/cjs/models/deck-version.js.map +1 -1
- package/cjs/models/deck.js +6 -3
- package/cjs/models/deck.js.map +1 -1
- package/cjs/models/dispatch-preview.js +3 -3
- package/cjs/models/dispatch-preview.js.map +1 -1
- package/cjs/models/dispatch.js +2 -2
- package/cjs/models/dispatch.js.map +1 -1
- package/cjs/models/envs.js.map +1 -1
- package/cjs/models/event-object.js +2 -2
- package/cjs/models/event-object.js.map +1 -1
- package/cjs/models/event.js +2 -2
- package/cjs/models/event.js.map +1 -1
- package/cjs/models/feed-data.js +2 -2
- package/cjs/models/feed-data.js.map +1 -1
- package/cjs/models/file.js +2 -2
- package/cjs/models/file.js.map +1 -1
- package/cjs/models/group.js +2 -2
- package/cjs/models/group.js.map +1 -1
- package/cjs/models/handover.js +2 -2
- package/cjs/models/handover.js.map +1 -1
- package/cjs/models/hosted-preso.js +2 -2
- package/cjs/models/hosted-preso.js.map +1 -1
- package/cjs/models/image.js +2 -2
- package/cjs/models/image.js.map +1 -1
- package/cjs/models/location.js +2 -2
- package/cjs/models/location.js.map +1 -1
- package/cjs/models/manifest-json.js +74 -57
- package/cjs/models/manifest-json.js.map +1 -1
- package/cjs/models/onshare.js +2 -2
- package/cjs/models/onshare.js.map +1 -1
- package/cjs/models/opportunity.js +2 -2
- package/cjs/models/opportunity.js.map +1 -1
- package/cjs/models/pack-diff.js +2 -2
- package/cjs/models/pack-diff.js.map +1 -1
- package/cjs/models/pack.js +2 -2
- package/cjs/models/pack.js.map +1 -1
- package/cjs/models/preset.js +22 -2
- package/cjs/models/preset.js.map +1 -1
- package/cjs/models/refresh-request.js +2 -2
- package/cjs/models/refresh-request.js.map +1 -1
- package/cjs/models/room.js +2 -2
- package/cjs/models/room.js.map +1 -1
- package/cjs/models/salesforce-lookup.js +2 -2
- package/cjs/models/salesforce-lookup.js.map +1 -1
- package/cjs/models/section-selection.js +2 -2
- package/cjs/models/section-selection.js.map +1 -1
- package/cjs/models/section.js +2 -2
- package/cjs/models/section.js.map +1 -1
- package/cjs/models/slide-selection.js +2 -2
- package/cjs/models/slide-selection.js.map +1 -1
- package/cjs/models/slide.js +2 -2
- package/cjs/models/slide.js.map +1 -1
- package/cjs/models/snapshot.js +2 -2
- package/cjs/models/snapshot.js.map +1 -1
- package/cjs/models/sub-slide.js +2 -2
- package/cjs/models/sub-slide.js.map +1 -1
- package/cjs/models/support-ticket.js +2 -2
- package/cjs/models/support-ticket.js.map +1 -1
- package/cjs/models/tag.js +54 -0
- package/cjs/models/tag.js.map +1 -0
- package/cjs/models/team.js +2 -2
- package/cjs/models/team.js.map +1 -1
- package/cjs/models/template.js +2 -2
- package/cjs/models/template.js.map +1 -1
- package/cjs/models/tenancy.js +2 -2
- package/cjs/models/tenancy.js.map +1 -1
- package/cjs/models/timing-log.js +20 -41
- package/cjs/models/timing-log.js.map +1 -1
- package/cjs/models/timing-log.spec.js +18 -86
- package/cjs/models/timing-log.spec.js.map +1 -1
- package/cjs/models/transcribe-socket.js +2 -2
- package/cjs/models/transcribe-socket.js.map +1 -1
- package/cjs/models/upload.js +2 -2
- package/cjs/models/upload.js.map +1 -1
- package/cjs/models/user.js +6 -4
- package/cjs/models/user.js.map +1 -1
- package/cjs/models/user.spec.js +10 -8
- package/cjs/models/user.spec.js.map +1 -1
- package/cjs/models.js +148 -0
- package/cjs/models.js.map +1 -1
- package/cjs/presentation/appointment-presentation.js +13 -5
- package/cjs/presentation/appointment-presentation.js.map +1 -1
- package/cjs/presentation/base-presentation-collection.js.map +1 -1
- package/cjs/presentation/base-presentation-model.js +65 -0
- package/cjs/presentation/base-presentation-model.js.map +1 -1
- package/cjs/presentation/base-presentation-model.spec.js +87 -0
- package/cjs/presentation/base-presentation-model.spec.js.map +1 -1
- package/cjs/presentation/presentation-deck.js +31 -20
- package/cjs/presentation/presentation-deck.js.map +1 -1
- package/cjs/presentation/presentation-deck.spec.js +15 -13
- package/cjs/presentation/presentation-deck.spec.js.map +1 -1
- package/cjs/presentation/presentation-decks.js +2 -2
- package/cjs/presentation/presentation-decks.js.map +1 -1
- package/cjs/presentation/presentation-section.js +36 -17
- package/cjs/presentation/presentation-section.js.map +1 -1
- package/cjs/presentation/presentation-section.spec.js +418 -0
- package/cjs/presentation/presentation-section.spec.js.map +1 -0
- package/cjs/presentation/presentation-sections.js +2 -2
- package/cjs/presentation/presentation-sections.js.map +1 -1
- package/cjs/presentation/presentation-slide.js +35 -18
- package/cjs/presentation/presentation-slide.js.map +1 -1
- package/cjs/presentation/presentation-slide.spec.js +294 -0
- package/cjs/presentation/presentation-slide.spec.js.map +1 -0
- package/cjs/presentation/presentation-slides.js +2 -2
- package/cjs/presentation/presentation-slides.js.map +1 -1
- package/cjs/presentation/presentation-subslide.js +11 -7
- package/cjs/presentation/presentation-subslide.js.map +1 -1
- package/cjs/presentation/presentation-subslide.spec.js +68 -20
- package/cjs/presentation/presentation-subslide.spec.js.map +1 -1
- package/cjs/presentation/presentation-subslides.js +2 -2
- package/cjs/presentation/presentation-subslides.js.map +1 -1
- package/cjs/presentation/presentation.js +19 -9
- package/cjs/presentation/presentation.js.map +1 -1
- package/cjs/presentation.js +10 -0
- package/cjs/presentation.js.map +1 -1
- package/cjs/state-register.js +11 -1
- package/cjs/state-register.js.map +1 -1
- package/cjs/sync.js +7 -7
- package/cjs/sync.js.map +1 -1
- package/cjs/utils.js +7 -7
- package/cjs/utils.js.map +1 -1
- package/cjs/utils.spec.js.map +1 -1
- package/config/rush-project.json +53 -0
- package/index.js +0 -1
- package/jest.config.js +4 -4
- package/package.json +17 -59
- package/setup-tests.js +2 -1
- package/src/api.js +3 -3
- package/src/api.spec.js +3 -4
- package/src/auth.js +6 -7
- package/src/auth.spec.js +3 -4
- package/src/collections/activity.js +5 -6
- package/src/collections/adjunct-sections.js +4 -4
- package/src/collections/adjunct-slides.js +4 -4
- package/src/collections/adjunct-sub-slides.js +2 -2
- package/src/collections/appointment-adjunct-tags.js +18 -0
- package/src/collections/appointment-deckversion-tags.js +21 -0
- package/src/collections/appointment-duplicates.js +2 -2
- package/src/collections/appointment-editors.js +2 -2
- package/src/collections/appointment-section-tags.js +18 -0
- package/src/collections/appointment-slide-tags.js +18 -0
- package/src/collections/appointment-tags.js +136 -0
- package/src/collections/appointments.js +18 -23
- package/src/collections/assets.js +2 -2
- package/src/collections/auto-adjuncts.js +5 -5
- package/src/collections/base.js +17 -18
- package/src/collections/base.spec.js +7 -8
- package/src/collections/cms-vals.js +3 -3
- package/src/collections/contacts.js +2 -2
- package/src/collections/created-assets.js +2 -2
- package/src/collections/customers.js +2 -2
- package/src/collections/deck-notes.js +2 -2
- package/src/collections/deck-versions.js +18 -15
- package/src/collections/decks.js +2 -2
- package/src/collections/deleted-assets.js +2 -2
- package/src/collections/dispatches.js +8 -13
- package/src/collections/event-objects.js +2 -2
- package/src/collections/events.js +2 -2
- package/src/collections/groups.js +2 -2
- package/src/collections/images.js +2 -2
- package/src/collections/locations.js +2 -2
- package/src/collections/opportunities.js +2 -2
- package/src/collections/pack-diffs.js +2 -2
- package/src/collections/packs.js +2 -2
- package/src/collections/presets.js +2 -2
- package/src/collections/section-selections.js +4 -4
- package/src/collections/sections.js +2 -2
- package/src/collections/slide-selections.js +4 -4
- package/src/collections/slides.js +2 -2
- package/src/collections/snapshots.js +2 -2
- package/src/collections/sub-slides.js +2 -2
- package/src/collections/tags.js +18 -0
- package/src/collections/teams.js +2 -2
- package/src/collections/templates.js +2 -2
- package/src/collections/uploads.js +2 -2
- package/src/collections/users.js +2 -2
- package/src/collections.js +6 -0
- package/src/index.js +1 -4
- package/src/middleware.js +1 -1
- package/src/middlewares/json.js +2 -2
- package/src/middlewares/redirect.js +1 -2
- package/src/models/activity-item.js +6 -6
- package/src/models/adjunct-section.js +5 -5
- package/src/models/adjunct-slide.js +5 -5
- package/src/models/adjunct-sub-slide.js +5 -5
- package/src/models/adjunct.js +4 -4
- package/src/models/api.js +1 -1
- package/src/models/appointment-adjunct-tags.js +41 -0
- package/src/models/appointment-deckversion-tags.js +41 -0
- package/src/models/appointment-duplicate.js +7 -7
- package/src/models/appointment-editor.js +6 -6
- package/src/models/appointment-section-tags.js +41 -0
- package/src/models/appointment-slide-tags.js +41 -0
- package/src/models/appointment-stats.js +5 -5
- package/src/models/appointment-tags.js +39 -0
- package/src/models/appointment-viewing.js +3 -3
- package/src/models/appointment.js +35 -29
- package/src/models/asset.js +5 -5
- package/src/models/auto-adjunct-key-check.js +5 -5
- package/src/models/auto-adjunct.js +4 -4
- package/src/models/base.js +36 -37
- package/src/models/base.spec.js +61 -62
- package/src/models/choicelist.js +2 -2
- package/src/models/cms-val.js +3 -3
- package/src/models/contact.js +9 -9
- package/src/models/customer.js +13 -13
- package/src/models/deck-note.js +4 -4
- package/src/models/deck-tags.js +52 -0
- package/src/models/deck-version.js +9 -8
- package/src/models/deck.js +8 -6
- package/src/models/dispatch-preview.js +6 -7
- package/src/models/dispatch.js +6 -7
- package/src/models/envs.js +1 -1
- package/src/models/event-object.js +6 -6
- package/src/models/event.js +7 -7
- package/src/models/feed-data.js +5 -5
- package/src/models/file.js +4 -4
- package/src/models/group.js +3 -3
- package/src/models/handover.js +5 -5
- package/src/models/hosted-preso.js +5 -5
- package/src/models/image.js +4 -4
- package/src/models/location.js +5 -5
- package/src/models/manifest-json.js +68 -30
- package/src/models/onshare.js +5 -5
- package/src/models/opportunity.js +5 -5
- package/src/models/pack-diff.js +5 -5
- package/src/models/pack.js +4 -4
- package/src/models/preset.js +24 -5
- package/src/models/refresh-request.js +6 -6
- package/src/models/room.js +3 -3
- package/src/models/salesforce-lookup.js +3 -3
- package/src/models/section-selection.js +6 -6
- package/src/models/section.js +7 -7
- package/src/models/slide-selection.js +6 -6
- package/src/models/slide.js +7 -7
- package/src/models/snapshot.js +5 -5
- package/src/models/sub-slide.js +5 -5
- package/src/models/support-ticket.js +4 -4
- package/src/models/tag.js +42 -0
- package/src/models/team.js +4 -4
- package/src/models/template.js +4 -4
- package/src/models/tenancy.js +5 -5
- package/src/models/timing-log.js +18 -18
- package/src/models/timing-log.spec.js +28 -29
- package/src/models/transcribe-socket.js +3 -3
- package/src/models/upload.js +3 -3
- package/src/models/user.js +24 -20
- package/src/models/user.spec.js +2 -2
- package/src/models.js +7 -0
- package/src/presentation/appointment-presentation.js +14 -10
- package/src/presentation/base-presentation-model.js +67 -5
- package/src/presentation/base-presentation-model.spec.js +114 -22
- package/src/presentation/presentation-deck.js +54 -52
- package/src/presentation/presentation-deck.spec.js +26 -27
- package/src/presentation/presentation-decks.js +2 -2
- package/src/presentation/presentation-section.js +62 -48
- package/src/presentation/presentation-section.spec.js +363 -0
- package/src/presentation/presentation-sections.js +2 -2
- package/src/presentation/presentation-slide.js +51 -36
- package/src/presentation/presentation-slide.spec.js +250 -0
- package/src/presentation/presentation-slides.js +2 -2
- package/src/presentation/presentation-subslide.js +24 -17
- package/src/presentation/presentation-subslide.spec.js +40 -12
- package/src/presentation/presentation-subslides.js +2 -2
- package/src/presentation/presentation.js +27 -15
- package/src/state-register.js +7 -0
- package/src/sync.js +21 -23
- package/src/utils.js +8 -7
- package/src/utils.spec.js +15 -15
- package/.editorconfig +0 -9
- package/.eslintrc +0 -25
- package/.prettierrc.js +0 -3
- package/jsdoc.json +0 -12
- package/yarn.lock +0 -8099
|
@@ -2,8 +2,8 @@ import "./template.js";
|
|
|
2
2
|
import "./team.js";
|
|
3
3
|
import "./deck.js";
|
|
4
4
|
|
|
5
|
-
import { register } from "../state-register.js";
|
|
6
5
|
import { BaseModel } from "./base.js";
|
|
6
|
+
import { register } from "../state-register.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @constructor
|
|
@@ -38,7 +38,7 @@ export const AutoAdjunctModel = BaseModel.extend(
|
|
|
38
38
|
key: "string",
|
|
39
39
|
enabled: "boolean",
|
|
40
40
|
sequence: "number",
|
|
41
|
-
tags: "array"
|
|
41
|
+
tags: "array",
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -48,8 +48,8 @@ export const AutoAdjunctModel = BaseModel.extend(
|
|
|
48
48
|
children: {
|
|
49
49
|
deck: "DeckModel",
|
|
50
50
|
template: "TemplateModel",
|
|
51
|
-
team: "TeamModel"
|
|
52
|
-
}
|
|
51
|
+
team: "TeamModel",
|
|
52
|
+
},
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
|
package/src/models/base.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DATE_FORMAT_T, removeMultiByteChars } from "../utils.js";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { Api } from "../api.js";
|
|
4
4
|
import Collection from "ampersand-rest-collection";
|
|
5
|
-
import
|
|
5
|
+
import Model from "ampersand-model";
|
|
6
|
+
import SuperAgentRequest from "superagent-bluebird-promise";
|
|
6
7
|
import _ from "lodash";
|
|
8
|
+
import dedent from "dedent-js";
|
|
9
|
+
import log from "../log.js";
|
|
7
10
|
import moment from "moment";
|
|
8
11
|
import qs from "qs";
|
|
9
|
-
import SuperAgentRequest from "superagent-bluebird-promise";
|
|
10
|
-
|
|
11
|
-
import { Api } from "../api.js";
|
|
12
|
-
import log from "../log.js";
|
|
13
12
|
import { registeredStates } from "../state-register.js";
|
|
14
13
|
import { sync } from "../sync.js";
|
|
15
|
-
import
|
|
14
|
+
import url2 from "url";
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @constructor
|
|
@@ -41,7 +40,7 @@ export const BaseModel = Model.extend(
|
|
|
41
40
|
|
|
42
41
|
constructor(data = {}, opts = {}) {
|
|
43
42
|
const options = _.defaults(opts, {
|
|
44
|
-
data: {}
|
|
43
|
+
data: {},
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
this._unsetChildren = {};
|
|
@@ -140,7 +139,7 @@ export const BaseModel = Model.extend(
|
|
|
140
139
|
const replacements = _.extend(
|
|
141
140
|
{},
|
|
142
141
|
{
|
|
143
|
-
detailKey: "number"
|
|
142
|
+
detailKey: "number",
|
|
144
143
|
},
|
|
145
144
|
this.urlMatchKeys
|
|
146
145
|
);
|
|
@@ -171,7 +170,7 @@ export const BaseModel = Model.extend(
|
|
|
171
170
|
// If that doesn't match, we can sometimes prevent a nasty log
|
|
172
171
|
// error from being thrown.
|
|
173
172
|
const split = urlStructure.split("/");
|
|
174
|
-
const argIndex = split.findIndex(val => {
|
|
173
|
+
const argIndex = split.findIndex((val) => {
|
|
175
174
|
return val.indexOf("{") === 0;
|
|
176
175
|
});
|
|
177
176
|
|
|
@@ -188,7 +187,7 @@ export const BaseModel = Model.extend(
|
|
|
188
187
|
let interpolatedString;
|
|
189
188
|
try {
|
|
190
189
|
interpolatedString = _.template(urlStructure.replace(/\./g, "_"), {
|
|
191
|
-
interpolate: /{([\s\S\.]+?)}/g
|
|
190
|
+
interpolate: /{([\s\S\.]+?)}/g,
|
|
192
191
|
})(regexes);
|
|
193
192
|
} catch (e) {
|
|
194
193
|
log.error(
|
|
@@ -249,10 +248,10 @@ export const BaseModel = Model.extend(
|
|
|
249
248
|
|
|
250
249
|
dataTypes: {
|
|
251
250
|
date: {
|
|
252
|
-
set: newVal => {
|
|
251
|
+
set: (newVal) => {
|
|
253
252
|
return {
|
|
254
253
|
val: newVal ? moment.utc(newVal).format(DATE_FORMAT_T) : null,
|
|
255
|
-
type: "date"
|
|
254
|
+
type: "date",
|
|
256
255
|
};
|
|
257
256
|
},
|
|
258
257
|
compare: (currentVal, newVal) => {
|
|
@@ -264,34 +263,34 @@ export const BaseModel = Model.extend(
|
|
|
264
263
|
return moment(currentVal).isSame(moment(newVal));
|
|
265
264
|
}
|
|
266
265
|
return currentVal !== newVal;
|
|
267
|
-
}
|
|
266
|
+
},
|
|
268
267
|
},
|
|
269
268
|
stringSanitized: {
|
|
270
|
-
set: newVal => {
|
|
269
|
+
set: (newVal) => {
|
|
271
270
|
return {
|
|
272
271
|
val: newVal ? removeMultiByteChars(newVal) : newVal,
|
|
273
|
-
type: "stringSanitized"
|
|
272
|
+
type: "stringSanitized",
|
|
274
273
|
};
|
|
275
274
|
},
|
|
276
275
|
compare: (currentVal, newVal) => {
|
|
277
276
|
return currentVal === newVal;
|
|
278
277
|
},
|
|
279
|
-
get: val => {
|
|
278
|
+
get: (val) => {
|
|
280
279
|
return val;
|
|
281
|
-
}
|
|
280
|
+
},
|
|
282
281
|
},
|
|
283
282
|
any: {
|
|
284
283
|
default: () => {
|
|
285
284
|
return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
285
|
+
},
|
|
286
|
+
},
|
|
288
287
|
},
|
|
289
288
|
|
|
290
289
|
/**
|
|
291
290
|
* @property {number} [id]
|
|
292
291
|
*/
|
|
293
292
|
props: {
|
|
294
|
-
id: { type: "any", required: false }
|
|
293
|
+
id: { type: "any", required: false },
|
|
295
294
|
},
|
|
296
295
|
|
|
297
296
|
/*
|
|
@@ -375,13 +374,13 @@ export const BaseModel = Model.extend(
|
|
|
375
374
|
// Set previously-initialised children & collections with new
|
|
376
375
|
// data retrieved during the fetch
|
|
377
376
|
|
|
378
|
-
Object.keys(this._children).forEach(key => {
|
|
377
|
+
Object.keys(this._children).forEach((key) => {
|
|
379
378
|
if (response[key]) {
|
|
380
379
|
this[key] = response[key];
|
|
381
380
|
}
|
|
382
381
|
});
|
|
383
382
|
|
|
384
|
-
Object.keys(this._collections).forEach(key => {
|
|
383
|
+
Object.keys(this._collections).forEach((key) => {
|
|
385
384
|
if (response[key]) {
|
|
386
385
|
this[key] = response[key];
|
|
387
386
|
}
|
|
@@ -389,7 +388,7 @@ export const BaseModel = Model.extend(
|
|
|
389
388
|
},
|
|
390
389
|
|
|
391
390
|
save() {
|
|
392
|
-
return Model.prototype.save.apply(this, arguments).tap(response => {
|
|
391
|
+
return Model.prototype.save.apply(this, arguments).tap((response) => {
|
|
393
392
|
this._updateResponse(response);
|
|
394
393
|
});
|
|
395
394
|
},
|
|
@@ -402,7 +401,7 @@ export const BaseModel = Model.extend(
|
|
|
402
401
|
this._options = _.extend({}, this._options, options);
|
|
403
402
|
|
|
404
403
|
this.isFetching = true;
|
|
405
|
-
return Model.prototype.fetch.apply(this, arguments).tap(response => {
|
|
404
|
+
return Model.prototype.fetch.apply(this, arguments).tap((response) => {
|
|
406
405
|
this.isFetching = false;
|
|
407
406
|
this._updateResponse(response);
|
|
408
407
|
});
|
|
@@ -414,7 +413,7 @@ export const BaseModel = Model.extend(
|
|
|
414
413
|
}
|
|
415
414
|
return SuperAgentRequest("OPTIONS", this.url())
|
|
416
415
|
.set(BaseModel.Auth.headers)
|
|
417
|
-
.then(res => {
|
|
416
|
+
.then((res) => {
|
|
418
417
|
if (res.body && res.body.actions) {
|
|
419
418
|
return res.body.actions;
|
|
420
419
|
}
|
|
@@ -441,13 +440,13 @@ export const BaseModel = Model.extend(
|
|
|
441
440
|
)
|
|
442
441
|
);
|
|
443
442
|
|
|
444
|
-
keys.forEach(key => {
|
|
443
|
+
keys.forEach((key) => {
|
|
445
444
|
if (!_.isUndefined(this._values[key])) {
|
|
446
445
|
attrs[key] = this._values[key];
|
|
447
446
|
}
|
|
448
447
|
});
|
|
449
448
|
|
|
450
|
-
Object.keys(this._expandedValues).forEach(key => {
|
|
449
|
+
Object.keys(this._expandedValues).forEach((key) => {
|
|
451
450
|
attrs[key] = this[key];
|
|
452
451
|
});
|
|
453
452
|
|
|
@@ -457,13 +456,13 @@ export const BaseModel = Model.extend(
|
|
|
457
456
|
// Unset all specified children and collection constructors and insert value
|
|
458
457
|
// definitions for them (necessary for Ampersand State to treat them as values)
|
|
459
458
|
_convertToValues() {
|
|
460
|
-
Object.keys(this._children).forEach(key => {
|
|
459
|
+
Object.keys(this._children).forEach((key) => {
|
|
461
460
|
this._definition[key] = { type: "any" };
|
|
462
461
|
this._unsetChildren[key] = this._children[key];
|
|
463
462
|
delete this._children[key];
|
|
464
463
|
});
|
|
465
464
|
|
|
466
|
-
Object.keys(this._collections).forEach(key => {
|
|
465
|
+
Object.keys(this._collections).forEach((key) => {
|
|
467
466
|
this._definition[key] = { type: "any" };
|
|
468
467
|
this._unsetCollections[key] = this._collections[key];
|
|
469
468
|
delete this._collections[key];
|
|
@@ -658,13 +657,13 @@ export const BaseModel = Model.extend(
|
|
|
658
657
|
return object;
|
|
659
658
|
}, {});
|
|
660
659
|
|
|
661
|
-
Object.keys(this._unsetCollections).forEach(key => {
|
|
660
|
+
Object.keys(this._unsetCollections).forEach((key) => {
|
|
662
661
|
if (this._unsetCollections[key].canBeEmpty && !this._values[key]) {
|
|
663
662
|
derived[key] = [];
|
|
664
663
|
}
|
|
665
664
|
});
|
|
666
665
|
|
|
667
|
-
Object.keys(this._unsetChildren).forEach(key => {
|
|
666
|
+
Object.keys(this._unsetChildren).forEach((key) => {
|
|
668
667
|
if (
|
|
669
668
|
this._unsetChildren[key].canBeEmpty &&
|
|
670
669
|
!this._values[key] &&
|
|
@@ -690,7 +689,7 @@ export const BaseModel = Model.extend(
|
|
|
690
689
|
return _.map(item.toJSON(), "url");
|
|
691
690
|
} else if (_.isArray(item)) {
|
|
692
691
|
// It's an array of urls or objects
|
|
693
|
-
return item.map(child => {
|
|
692
|
+
return item.map((child) => {
|
|
694
693
|
return this._retrieveURL(child);
|
|
695
694
|
});
|
|
696
695
|
} else if (typeof item === "object" && item !== null) {
|
|
@@ -698,7 +697,7 @@ export const BaseModel = Model.extend(
|
|
|
698
697
|
}
|
|
699
698
|
|
|
700
699
|
return null;
|
|
701
|
-
}
|
|
700
|
+
},
|
|
702
701
|
}
|
|
703
702
|
);
|
|
704
703
|
|
|
@@ -807,11 +806,11 @@ function replacePropertyDefinition(object, name) {
|
|
|
807
806
|
|
|
808
807
|
return value;
|
|
809
808
|
},
|
|
810
|
-
configurable: true
|
|
809
|
+
configurable: true,
|
|
811
810
|
});
|
|
812
811
|
}
|
|
813
812
|
|
|
814
813
|
// Make matchesURL available as a static method
|
|
815
|
-
BaseModel.matchesURL = function(url) {
|
|
814
|
+
BaseModel.matchesURL = function (url) {
|
|
816
815
|
return this.prototype.matchesURL(url);
|
|
817
816
|
};
|
package/src/models/base.spec.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import moment from "moment";
|
|
2
|
-
import { G } from "sp-test/api";
|
|
3
|
-
import td from "testdouble";
|
|
4
|
-
|
|
5
1
|
import { Api } from "../api.js";
|
|
6
2
|
import { BaseCollection } from "../collections/base.js";
|
|
7
|
-
import log from "../log.js";
|
|
8
|
-
import { DATE_FORMAT_T } from "../utils.js";
|
|
9
3
|
import { BaseModel } from "./base.js";
|
|
4
|
+
import { DATE_FORMAT_T } from "../utils.js";
|
|
5
|
+
import { G } from "sp-test/api";
|
|
6
|
+
import log from "../log.js";
|
|
7
|
+
import moment from "moment";
|
|
8
|
+
import td from "testdouble";
|
|
10
9
|
|
|
11
|
-
it("should set date types correctly (SP-2698)", function() {
|
|
10
|
+
it("should set date types correctly (SP-2698)", function () {
|
|
12
11
|
const TestModel = BaseModel.extend({ props: { testDate: "date" } });
|
|
13
12
|
|
|
14
13
|
const model = new TestModel();
|
|
@@ -49,22 +48,22 @@ it("should not append a slash to a get query", () => {
|
|
|
49
48
|
expect(model.url()).toEqual("/api/tests/?foo=bar");
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
it("should replace child model strings with the registered model", function() {
|
|
51
|
+
it("should replace child model strings with the registered model", function () {
|
|
53
52
|
const TestModel = G(BaseModel, "TestModel");
|
|
54
53
|
const Model = G(
|
|
55
54
|
BaseModel.extend({
|
|
56
|
-
children: { test: "TestModel" }
|
|
55
|
+
children: { test: "TestModel" },
|
|
57
56
|
})
|
|
58
57
|
);
|
|
59
58
|
const model = new Model({ test: 1 });
|
|
60
59
|
expect(model.test).toBeInstanceOf(TestModel);
|
|
61
60
|
});
|
|
62
61
|
|
|
63
|
-
it("should allow the model to be passed in", function() {
|
|
62
|
+
it("should allow the model to be passed in", function () {
|
|
64
63
|
const TestModel = G(BaseModel, "TestModel");
|
|
65
64
|
const Model = G(
|
|
66
65
|
BaseModel.extend({
|
|
67
|
-
children: { test: "TestModel" }
|
|
66
|
+
children: { test: "TestModel" },
|
|
68
67
|
})
|
|
69
68
|
);
|
|
70
69
|
const model = new Model({ test: new TestModel({ id: 1 }) });
|
|
@@ -72,11 +71,11 @@ it("should allow the model to be passed in", function() {
|
|
|
72
71
|
expect(model.test).toBeInstanceOf(TestModel);
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
it("should reference parent model if foreign key exists", function() {
|
|
74
|
+
it("should reference parent model if foreign key exists", function () {
|
|
76
75
|
G(BaseModel, "TestModel");
|
|
77
76
|
const Model = G(
|
|
78
77
|
BaseModel.extend({
|
|
79
|
-
children: { test: "TestModel" }
|
|
78
|
+
children: { test: "TestModel" },
|
|
80
79
|
})
|
|
81
80
|
);
|
|
82
81
|
const model = new Model({ test: 1 });
|
|
@@ -86,70 +85,70 @@ it("should reference parent model if foreign key exists", function() {
|
|
|
86
85
|
it("should throw an error if the child model doesn't exist", () => {
|
|
87
86
|
const Model = G(
|
|
88
87
|
BaseModel.extend({
|
|
89
|
-
children: { test: "DoesntExist" }
|
|
88
|
+
children: { test: "DoesntExist" },
|
|
90
89
|
})
|
|
91
90
|
);
|
|
92
91
|
|
|
93
92
|
expect(() => new Model()).toThrow();
|
|
94
93
|
});
|
|
95
94
|
|
|
96
|
-
it("should convert a url into a model", function() {
|
|
95
|
+
it("should convert a url into a model", function () {
|
|
97
96
|
G(BaseModel.extend({ modelName: "tests" }), "TestModel");
|
|
98
97
|
const Model = G(
|
|
99
98
|
BaseModel.extend({
|
|
100
|
-
children: { test: "TestModel" }
|
|
99
|
+
children: { test: "TestModel" },
|
|
101
100
|
})
|
|
102
101
|
);
|
|
103
102
|
const model = new Model({ test: "/api/tests/1/" });
|
|
104
103
|
expect(model.test.id).toEqual(1);
|
|
105
104
|
});
|
|
106
105
|
|
|
107
|
-
it("should convert an object into a model", function() {
|
|
106
|
+
it("should convert an object into a model", function () {
|
|
108
107
|
G(BaseModel, "TestModel");
|
|
109
108
|
const Model = G(
|
|
110
109
|
BaseModel.extend({
|
|
111
|
-
children: { test: "TestModel" }
|
|
110
|
+
children: { test: "TestModel" },
|
|
112
111
|
})
|
|
113
112
|
);
|
|
114
113
|
const model = new Model({ test: { id: 1 } });
|
|
115
114
|
expect(model.test.id).toEqual(1);
|
|
116
115
|
});
|
|
117
116
|
|
|
118
|
-
it("should replace collection strings with their registered state", function() {
|
|
117
|
+
it("should replace collection strings with their registered state", function () {
|
|
119
118
|
G(BaseModel, "TestModel");
|
|
120
119
|
const TestCollection = G(
|
|
121
120
|
BaseCollection.extend({
|
|
122
|
-
model: "TestModel"
|
|
121
|
+
model: "TestModel",
|
|
123
122
|
}),
|
|
124
123
|
"TestCollection"
|
|
125
124
|
);
|
|
126
125
|
const Model = G(
|
|
127
126
|
BaseModel.extend({
|
|
128
|
-
collections: { tests: "TestCollection" }
|
|
127
|
+
collections: { tests: "TestCollection" },
|
|
129
128
|
})
|
|
130
129
|
);
|
|
131
130
|
const model = new Model({
|
|
132
|
-
tests: [{ id: 1 }]
|
|
131
|
+
tests: [{ id: 1 }],
|
|
133
132
|
});
|
|
134
133
|
expect(model.tests).toBeInstanceOf(TestCollection);
|
|
135
134
|
});
|
|
136
135
|
|
|
137
|
-
it("should allow a list of models to be passed into a collection", function() {
|
|
136
|
+
it("should allow a list of models to be passed into a collection", function () {
|
|
138
137
|
const TestModel = G(BaseModel, "TestModel");
|
|
139
138
|
G(
|
|
140
139
|
BaseCollection.extend({
|
|
141
|
-
model: "TestModel"
|
|
140
|
+
model: "TestModel",
|
|
142
141
|
}),
|
|
143
142
|
"TestCollection"
|
|
144
143
|
);
|
|
145
144
|
const Model = G(
|
|
146
145
|
BaseModel.extend({
|
|
147
|
-
collections: { tests: "TestCollection" }
|
|
146
|
+
collections: { tests: "TestCollection" },
|
|
148
147
|
})
|
|
149
148
|
);
|
|
150
149
|
const test = new TestModel({ id: 1 });
|
|
151
150
|
const model = new Model({
|
|
152
|
-
tests: [test]
|
|
151
|
+
tests: [test],
|
|
153
152
|
});
|
|
154
153
|
expect(model.tests.first().id).toEqual(1);
|
|
155
154
|
});
|
|
@@ -158,24 +157,24 @@ it("should allow a collection to be passed in directly", () => {
|
|
|
158
157
|
G(BaseModel, "TestModel");
|
|
159
158
|
const TestCollection = G(
|
|
160
159
|
BaseCollection.extend({
|
|
161
|
-
model: "TestModel"
|
|
160
|
+
model: "TestModel",
|
|
162
161
|
}),
|
|
163
162
|
"TestCollection"
|
|
164
163
|
);
|
|
165
164
|
const Model = G(
|
|
166
165
|
BaseModel.extend({
|
|
167
|
-
collections: { tests: "TestCollection" }
|
|
166
|
+
collections: { tests: "TestCollection" },
|
|
168
167
|
})
|
|
169
168
|
);
|
|
170
169
|
const model = new Model({
|
|
171
|
-
tests: new TestCollection([{ id: 1 }])
|
|
170
|
+
tests: new TestCollection([{ id: 1 }]),
|
|
172
171
|
});
|
|
173
172
|
expect(model.tests).toBeInstanceOf(TestCollection);
|
|
174
173
|
});
|
|
175
174
|
|
|
176
175
|
it("should throw an error if the child collection doesn't exist", () => {
|
|
177
176
|
const Model = BaseModel.extend({
|
|
178
|
-
collections: { mustFail: "DoesntExist" }
|
|
177
|
+
collections: { mustFail: "DoesntExist" },
|
|
179
178
|
});
|
|
180
179
|
expect(() => new Model()).toThrow();
|
|
181
180
|
});
|
|
@@ -184,13 +183,13 @@ it("should convert a url into a collection", () => {
|
|
|
184
183
|
G(BaseModel, "TestModel");
|
|
185
184
|
const TestCollection = G(
|
|
186
185
|
BaseCollection.extend({
|
|
187
|
-
model: "TestModel"
|
|
186
|
+
model: "TestModel",
|
|
188
187
|
}),
|
|
189
188
|
"TestCollection"
|
|
190
189
|
);
|
|
191
190
|
const Model = G(
|
|
192
191
|
BaseModel.extend({
|
|
193
|
-
collections: { tests: "TestCollection" }
|
|
192
|
+
collections: { tests: "TestCollection" },
|
|
194
193
|
})
|
|
195
194
|
);
|
|
196
195
|
const model = new Model({ tests: "/api/tests/" });
|
|
@@ -202,25 +201,25 @@ it("should convert an array of objects into a collection", () => {
|
|
|
202
201
|
G(BaseCollection.extend({ model: "TestModel" }), "TestCollection");
|
|
203
202
|
const Model = G(
|
|
204
203
|
BaseModel.extend({
|
|
205
|
-
collections: { tests: "TestCollection" }
|
|
204
|
+
collections: { tests: "TestCollection" },
|
|
206
205
|
})
|
|
207
206
|
);
|
|
208
207
|
const model = new Model({
|
|
209
|
-
tests: [{ id: 1 }, { id: 2 }]
|
|
208
|
+
tests: [{ id: 1 }, { id: 2 }],
|
|
210
209
|
});
|
|
211
210
|
expect(model.tests.at(0).id).toEqual(1);
|
|
212
211
|
expect(model.tests.at(1).id).toEqual(2);
|
|
213
212
|
});
|
|
214
213
|
|
|
215
|
-
it("should correctly sanitize strings of multibyte characters (preserving spaces)", function() {
|
|
214
|
+
it("should correctly sanitize strings of multibyte characters (preserving spaces)", function () {
|
|
216
215
|
const TestModel = BaseModel.extend({
|
|
217
216
|
props: {
|
|
218
217
|
normalString: "string",
|
|
219
218
|
control: "stringSanitized",
|
|
220
219
|
withSpace: "stringSanitized",
|
|
221
220
|
withoutSpace: "stringSanitized",
|
|
222
|
-
withSpecialCharacters: "stringSanitized"
|
|
223
|
-
}
|
|
221
|
+
withSpecialCharacters: "stringSanitized",
|
|
222
|
+
},
|
|
224
223
|
});
|
|
225
224
|
|
|
226
225
|
const model = new TestModel({
|
|
@@ -228,7 +227,7 @@ it("should correctly sanitize strings of multibyte characters (preserving spaces
|
|
|
228
227
|
control: "ABC",
|
|
229
228
|
withSpace: "Aâ BâCç",
|
|
230
229
|
withoutSpace: "AãB®C",
|
|
231
|
-
withSpecialCharacters: "!@#$%^&*()_+"
|
|
230
|
+
withSpecialCharacters: "!@#$%^&*()_+",
|
|
232
231
|
});
|
|
233
232
|
|
|
234
233
|
expect(model.normalString).toEqual("Aâ BâCç");
|
|
@@ -242,8 +241,8 @@ it("should allow passing in another model into a model", () => {
|
|
|
242
241
|
const TestModel = BaseModel.extend({
|
|
243
242
|
modelName: "test",
|
|
244
243
|
props: {
|
|
245
|
-
foo: "string"
|
|
246
|
-
}
|
|
244
|
+
foo: "string",
|
|
245
|
+
},
|
|
247
246
|
});
|
|
248
247
|
|
|
249
248
|
const firstModel = new TestModel({ foo: "bar" });
|
|
@@ -255,7 +254,7 @@ it("should allow passing in another model into a model", () => {
|
|
|
255
254
|
it("should retrieve the ID when there is no resource URL", () => {
|
|
256
255
|
const testURL = "http://localhost:9980/api/test/34/";
|
|
257
256
|
const TestModel = BaseModel.extend({
|
|
258
|
-
modelName: "test"
|
|
257
|
+
modelName: "test",
|
|
259
258
|
});
|
|
260
259
|
|
|
261
260
|
const testModel = new TestModel({ url: testURL });
|
|
@@ -267,7 +266,7 @@ it("should retrieve the ID when there is no resource URL", () => {
|
|
|
267
266
|
it("should retrieve the ID when the resource URL is the same as the hostname", () => {
|
|
268
267
|
const testURL = "http://localhost:9980/api/test/34/";
|
|
269
268
|
const TestModel = BaseModel.extend({
|
|
270
|
-
modelName: "test"
|
|
269
|
+
modelName: "test",
|
|
271
270
|
});
|
|
272
271
|
|
|
273
272
|
TestModel.prototype.getResourceURL = jest.fn(() => {
|
|
@@ -282,7 +281,7 @@ it("should retrieve the ID when the resource URL is the same as the hostname", (
|
|
|
282
281
|
it("should retrieve the ID when the resource hostname is different to the URL hostname", () => {
|
|
283
282
|
const testURL = "http://some-hostname/api/test/34/";
|
|
284
283
|
const TestModel = BaseModel.extend({
|
|
285
|
-
modelName: "test"
|
|
284
|
+
modelName: "test",
|
|
286
285
|
});
|
|
287
286
|
|
|
288
287
|
TestModel.prototype.getResourceURL = jest.fn(() => {
|
|
@@ -298,8 +297,8 @@ it("should pass through values into a derived model", () => {
|
|
|
298
297
|
const DerivedModel = BaseModel.extend({
|
|
299
298
|
modelName: "derived",
|
|
300
299
|
props: {
|
|
301
|
-
name: "string"
|
|
302
|
-
}
|
|
300
|
+
name: "string",
|
|
301
|
+
},
|
|
303
302
|
});
|
|
304
303
|
const TestModel = BaseModel.extend({
|
|
305
304
|
modelName: "test",
|
|
@@ -307,9 +306,9 @@ it("should pass through values into a derived model", () => {
|
|
|
307
306
|
myDerivedModel: {
|
|
308
307
|
fn() {
|
|
309
308
|
return new DerivedModel();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
313
312
|
});
|
|
314
313
|
|
|
315
314
|
const model = new TestModel({ myDerivedModel: { id: 1, name: "foo" } });
|
|
@@ -322,15 +321,15 @@ it("should pass through values into a derived collection", () => {
|
|
|
322
321
|
BaseModel.extend({
|
|
323
322
|
modelName: "derived",
|
|
324
323
|
props: {
|
|
325
|
-
name: "string"
|
|
326
|
-
}
|
|
324
|
+
name: "string",
|
|
325
|
+
},
|
|
327
326
|
}),
|
|
328
327
|
"DerivedModel"
|
|
329
328
|
);
|
|
330
329
|
|
|
331
330
|
const DerivedCollection = G(
|
|
332
331
|
BaseCollection.extend({
|
|
333
|
-
model: "DerivedModel"
|
|
332
|
+
model: "DerivedModel",
|
|
334
333
|
})
|
|
335
334
|
);
|
|
336
335
|
|
|
@@ -341,15 +340,15 @@ it("should pass through values into a derived collection", () => {
|
|
|
341
340
|
myDerivedCollection: {
|
|
342
341
|
fn() {
|
|
343
342
|
return new DerivedCollection();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
},
|
|
347
346
|
}),
|
|
348
347
|
"TestModel"
|
|
349
348
|
);
|
|
350
349
|
|
|
351
350
|
const model = new TestModel({
|
|
352
|
-
myDerivedCollection: [{ id: 1, name: "foo" }]
|
|
351
|
+
myDerivedCollection: [{ id: 1, name: "foo" }],
|
|
353
352
|
});
|
|
354
353
|
expect(model.myDerivedCollection.first().id).toEqual(1);
|
|
355
354
|
expect(model.myDerivedCollection.first().name).toEqual("foo");
|
|
@@ -358,14 +357,14 @@ it("should pass through values into a derived collection", () => {
|
|
|
358
357
|
describe(".matchesURL", () => {
|
|
359
358
|
it("should have a model match the right url", () => {
|
|
360
359
|
const TestModel = G(BaseModel, "TestModel").extend({
|
|
361
|
-
modelName: "foo"
|
|
360
|
+
modelName: "foo",
|
|
362
361
|
});
|
|
363
362
|
expect(TestModel.matchesURL("/api/foo/1/")).toEqual(true);
|
|
364
363
|
});
|
|
365
364
|
|
|
366
365
|
it("should have a model not match the wrong url", () => {
|
|
367
366
|
const TestModel = G(BaseModel, "TestModel").extend({
|
|
368
|
-
modelName: "foo"
|
|
367
|
+
modelName: "foo",
|
|
369
368
|
});
|
|
370
369
|
expect(TestModel.matchesURL("/api/bar/1/")).toEqual(false);
|
|
371
370
|
});
|
|
@@ -376,7 +375,7 @@ describe(".matchesURL", () => {
|
|
|
376
375
|
modelName: "bar",
|
|
377
376
|
getResourceURL() {
|
|
378
377
|
return "/api/bar/{foo}/";
|
|
379
|
-
}
|
|
378
|
+
},
|
|
380
379
|
});
|
|
381
380
|
expect(TestModel.matchesURL("/api/foo/1/")).toEqual(false);
|
|
382
381
|
expect(errorFn).not.toBeCalled();
|
|
@@ -388,7 +387,7 @@ describe(".matchesURL", () => {
|
|
|
388
387
|
modelName: "bar",
|
|
389
388
|
getResourceURL() {
|
|
390
389
|
return "/api/bar/{foo}/";
|
|
391
|
-
}
|
|
390
|
+
},
|
|
392
391
|
});
|
|
393
392
|
expect(TestModel.matchesURL("/api/bar/1/")).toEqual(false);
|
|
394
393
|
expect(errorFn).toBeCalled();
|
|
@@ -399,11 +398,11 @@ describe(".matchesURL", () => {
|
|
|
399
398
|
modelName: "bar",
|
|
400
399
|
urlMatchKeys: {
|
|
401
400
|
foo: "string",
|
|
402
|
-
bar: "number"
|
|
401
|
+
bar: "number",
|
|
403
402
|
},
|
|
404
403
|
getResourceURL() {
|
|
405
404
|
return "/api/bar/{bar}/{foo}/";
|
|
406
|
-
}
|
|
405
|
+
},
|
|
407
406
|
});
|
|
408
407
|
expect(TestModel.matchesURL("/api/bar/1/hello/1/")).toEqual(true);
|
|
409
408
|
});
|
|
@@ -415,7 +414,7 @@ describe(".matchesURL", () => {
|
|
|
415
414
|
const ActivityModel = G("ActivityItemModel").extend({
|
|
416
415
|
getResourceURL() {
|
|
417
416
|
return `${endpoint}activities/`;
|
|
418
|
-
}
|
|
417
|
+
},
|
|
419
418
|
});
|
|
420
419
|
expect(ActivityModel.matchesURL(url)).toEqual(true);
|
|
421
420
|
});
|
package/src/models/choicelist.js
CHANGED
package/src/models/cms-val.js
CHANGED
|
@@ -20,7 +20,7 @@ export const CMSValModel = BaseModel.extend(
|
|
|
20
20
|
key: "string",
|
|
21
21
|
scope: "string",
|
|
22
22
|
mime: "string",
|
|
23
|
-
value: "string"
|
|
23
|
+
value: "string",
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ export const CMSValModel = BaseModel.extend(
|
|
|
31
31
|
children: {
|
|
32
32
|
user: "UserModel",
|
|
33
33
|
deck: "DeckModel",
|
|
34
|
-
team: "TeamModel"
|
|
34
|
+
team: "TeamModel",
|
|
35
35
|
},
|
|
36
36
|
|
|
37
37
|
url() {
|
|
@@ -54,7 +54,7 @@ export const CMSValModel = BaseModel.extend(
|
|
|
54
54
|
data.user = this.user ? this.user.url() : undefined;
|
|
55
55
|
|
|
56
56
|
return data;
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
|