Commit Graph

1695 Commits

Author SHA1 Message Date
Rand McKinney 242bcec539 Update model.js
Add `extend()` method to API docs.
2015-04-28 10:06:14 -07:00
Miroslav Bajtoš b9493cdb45 2.17.2
* Fix regression in Model.getApp() (Miroslav Bajtoš)
2015-04-28 18:08:55 +02:00
Miroslav Bajtoš ff5f507560 Merge pull request #1343 from strongloop/fix/app-getApp
Fix regression in Model.getApp()
2015-04-28 18:08:27 +02:00
Miroslav Bajtoš b6b76d538c Fix regression in Model.getApp()
This patch fixes the method Model.getApp() that started to report
the following error after b61fae5 was landed:

assert.js:88
  throw new assert.AssertionError({
        ^
AssertionError: undefined == true
    at loopback/loopback/lib/model.js:392:7
    at EventEmitter.<anonymous> (loopback/loopback/lib/model.js:222:9)
    at EventEmitter.g (events.js:257:16)
    at emitOne (events.js:77:13)
    at EventEmitter.emit (events.js:166:7)
    at EventEmitter.app.model (loopback/loopback/lib/application.js:157:9)
2015-04-28 12:49:57 +02:00
Miroslav Bajtoš f93590de1b 2.17.1
* Allow dataSource === false (Raymond Feng)

 * Fix remoting metadata for User.login#include (Miroslav Bajtoš)
2015-04-28 08:09:44 +02:00
Miroslav Bajtoš da50d6ffb0 Merge pull request #1332 from strongloop/fix/user-login-include
Fix remoting metadata for User.login#include
2015-04-28 08:08:25 +02:00
Raymond Feng 99d23bb7c4 Merge pull request #1329 from strongloop/feature/allow-datasource-false
Allow dataSource === false
2015-04-24 08:46:31 -07:00
Raymond Feng f798882e9a Allow dataSource === false 2015-04-24 08:32:17 -07:00
Miroslav Bajtoš 03d9f64c82 Fix remoting metadata for User.login#include
Change the type of the "include" argument to "string array".

The type used to be "string" before and thus requests sending multiple
include items were technically incorrect.
2015-04-24 08:58:30 +02:00
Raymond Feng 42318f428c 2.17.0
* Disable inclusion of User.accessTokens (Raymond Feng)

 * Upgrade test fixtures to use LB 2.x layout (Raymond Feng)
2015-04-21 10:46:42 -07:00
Raymond Feng a4121ee3d6 Merge pull request #1318 from strongloop/feature/disable-include-access-tokens
Disable inclusion of User.accessTokens
2015-04-21 10:43:41 -07:00
Raymond Feng bdc741520e Disable inclusion of User.accessTokens 2015-04-20 11:44:07 -07:00
Raymond Feng ca004adfc6 Merge pull request #1301 from strongloop/feature/disable-include-access-tokens
Upgrade test fixtures to 2.x project layouts
2015-04-20 11:43:19 -07:00
Raymond Feng 12e19e36ea Upgrade test fixtures to use LB 2.x layout 2015-04-20 09:23:44 -07:00
Miroslav Bajtoš 69b4972590 2.16.3
* Rework global registry to be per-module-instance (Miroslav Bajtoš)
2015-04-17 19:36:53 +02:00
Miroslav Bajtoš d84a6466ad Merge pull request #1311 from strongloop/fix/global-registry
Rework global registry to be per-module-instance
2015-04-17 19:33:10 +02:00
Miroslav Bajtoš f130b7aa01 Rework global registry to be per-module-instance
Fix a regression introduced by b917075 where two loopback projects,
each one using a different instance of loopback module, were
sharing the global registry and thus not working correctly.

The issue was discovered by unit-tests in loopback-workspace.
2015-04-17 19:26:05 +02:00
Miroslav Bajtoš 73ee01f27c 2.16.1
* Add back loopback properties like modelBuilder (Miroslav Bajtoš)
2015-04-17 18:35:30 +02:00
Miroslav Bajtoš 7e99912669 Merge pull request #1310 from strongloop/fix/regression-in-loopback-props
Add back loopback properties like modelBuilder
2015-04-17 18:34:55 +02:00
Miroslav Bajtoš 4d0a824757 Add back loopback properties like modelBuilder
The commit b917075 accidentally removed a couple of properties,
this commit is bringing them back:

 - loopback.modelRegistry
 - loopback.defaultDataSources

A unit-test was added to prevent this kind of regressions in the future.
2015-04-17 18:05:25 +02:00
Raymond Feng 5158df8790 2.16.0
* Expose the `filter` argument for findById (Raymond Feng)

 * fixed the missing '.' in various description fields. (Edmond Lau)

 * Conflict resolution and Access control (Miroslav Bajtoš)

 * Fix the typo (Raymond Feng)

 * Fix PersistedModel._defineChangeModel (Miroslav Bajtoš)

 * AccessControl for change replication (Miroslav Bajtoš)

 * test: remove global autoAttach (Miroslav Bajtoš)

 * Add support for app level Model isolation (Ritchie Martori)

 * Implement ModelCtor.afterRemoteError (Miroslav Bajtoš)

 * Code cleanup, add Model._runWhenAttachedToApp (Miroslav Bajtoš)

 * Refactor Model and PersistedModel registration (Miroslav Bajtoš)

 * Fix the style issue (Raymond Feng)

 * Add missing error handlers to checkpoints() (Miroslav Bajtoš)

 * Fix where param format (Rand McKinney)

 * Test embedsOne CRUD methods (Fabien Franzen)
2015-04-16 15:13:49 -07:00
Raymond Feng 3dcde7994b Merge pull request #1306 from strongloop/feature/allow-filter-on-findById
Expose the `filter` argument for findById
2015-04-16 15:12:50 -07:00
Raymond Feng 2bf69a1171 Expose the `filter` argument for findById 2015-04-16 15:02:41 -07:00
Miroslav Bajtoš b6a278861f Merge pull request #1304 from edlau/master
fixed the missing '.' in various description fields.
2015-04-16 13:52:47 +02:00
Edmond Lau ef7c1439b6 fixed the missing '.' in various description fields. 2015-04-15 09:47:38 -04:00
Miroslav Bajtoš bd973def63 Merge pull request #1294 from strongloop/feature/conflict-resolution-access-control
Conflict resolution and Access control
2015-04-14 09:36:40 +02:00
Miroslav Bajtoš cf2acb3cd2 Conflict resolution and Access control
Add end-to-end unit-tests verifying enforcement of access control during
conflict resolution.

Implement two facade methods providing REST API for Change methods used
by conflict resolution:

    PersistedModel.findLastChange
    GET /api/{model.pluralName}/{id}/changes/last

    PersistedModel.updateLastChange
    PUT /api/{model.pluralName}/{id}/changes/last

By providing these two methods on PersistedModel, replication users
don't have to expose the Change model via the REST API. What's even
more important, these two methods use the same set of ACL rules
as other (regular) PersistedModel methods.

Rework `Conflict.prototype.changes()` and `Conflict.prototype.resolve()`
to use these new facade methods.

Implement a new method `Conflict.prototype.swapParties()` that provides
better API for the situation when a conflict detected in Remote->Local
replication should be resolved locally (i.e. in the replication target).
2015-04-14 08:23:24 +02:00
Raymond Feng b4c487b191 Fix the typo 2015-04-10 11:03:55 -07:00
Miroslav Bajtoš 28acffd7dd Fix PersistedModel._defineChangeModel
Correctly handle the case when the model is attached multiple times
during the lifecycle, this happens because `loopback.createModel`
always makes an attempt to auto-attach.
2015-04-08 11:55:03 +02:00
Miroslav Bajtoš b18d2516a4 Merge pull request #1270 from strongloop/feature/replication-access-control
Basic access control for change replication
2015-04-07 20:00:27 +02:00
Miroslav Bajtoš 9c5fe088e3 AccessControl for change replication
1) Add integration tests running change replication over REST to verify
that access control at model level is correctly enforced.

2) Implement a new access type "REPLICATE" that allows principals
to create new checkpoints, even though they don't have full WRITE
access to the model. Together with the "READ" permission, these
two types allow principals to replicate (pull) changes from the server.

Note that anybody having "WRITE" access type is automatically
granted "REPLICATE" type too.

3) Add a new model option "enableRemoteReplication" that exposes
replication methods via strong remoting, but does not configure
change rectification. This option should be used the clients
when setting up Remote models attached to the server via the remoting
connector.
2015-04-07 19:53:58 +02:00
Miroslav Bajtoš 699bc7aa97 test: remove global autoAttach 2015-04-07 15:25:18 +02:00
Miroslav Bajtoš b61fae58f6 Merge pull request #1272 from strongloop/feature/after-remote-error-hook
Model.afterRemoteError hook
2015-04-07 09:47:51 +02:00
Ritchie Martori 93960b838d Merge pull request #1212 from strongloop/feature/app-registries
Per-app Models
2015-04-03 13:13:34 -07:00
Ritchie Martori b9170751bc Add support for app level Model isolation
- `loopback.registry` is now a true global registry
 - `app.registry` is unique per app object
 - `Model.registry` is set when a Model is created using any registry method
 - `loopback.localRegistry` and `loopback({localRegistry: true})` when set to `true` this will create a `Registry` per `Application`. It defaults to `false`.
2015-04-03 11:48:45 -07:00
Miroslav Bajtoš dd83be99f0 Implement ModelCtor.afterRemoteError 2015-04-03 10:31:03 +02:00
Miroslav Bajtoš a71c8253e2 Code cleanup, add Model._runWhenAttachedToApp 2015-04-03 10:06:49 +02:00
Miroslav Bajtoš 5a51c7f0fa Merge pull request #1271 from strongloop/refactor/core-models
Refactor Model and PersistedModel registration
2015-04-03 09:40:21 +02:00
Miroslav Bajtoš c72c134d80 Refactor Model and PersistedModel registration
Modify the files to export a model factory function accepting
a `registry` argument. This is a preparation step for per-application
models - see #1212.
2015-04-03 09:26:19 +02:00
Raymond Feng 72d547971a Merge branch 'fabien-fix/embeds-one-remoting' 2015-04-02 08:45:30 -07:00
Raymond Feng 64ccb785c2 Fix the style issue 2015-04-02 08:45:04 -07:00
Raymond Feng 9af828efd4 Merge branch 'fix/embeds-one-remoting' of https://github.com/fabien/loopback into fabien-fix/embeds-one-remoting 2015-04-02 08:41:49 -07:00
Miroslav Bajtoš cdbdc4b55d Merge pull request #1269 from strongloop/fix/replication-checkpoints
Add missing error handlers to checkpoints()
2015-04-02 14:21:46 +02:00
Miroslav Bajtoš 8493ede19e Add missing error handlers to checkpoints() 2015-04-02 14:14:32 +02:00
Rand McKinney 8a1fe0b744 Fix where param format 2015-04-01 11:29:35 -07:00
Miroslav Bajtoš 3ef7dedfa4 2.15.0
* Improve error handling in replication (Miroslav Bajtoš)

 * Add `loopback.runInContext` (Miroslav Bajtoš)

 * Fix style issues (Raymond Feng)

 * Document the new third callback arg of replicate() (Miroslav Bajtoš)

 * Fix API doc for updateAll/deleteAll (Miroslav Bajtoš)

 * Import subset of underscore.string scripts only (Miroslav Bajtoš)

 * Use `ctx.instance` provided by "after delete" hook (Miroslav Bajtoš)

 * Add conflict resolution API (Miroslav Bajtoš)

 * Detect 3rd-party changes made during replication (Miroslav Bajtoš)

 * Ability to pass in custom verification token generator This commit adds the ability for the developer to use a custom token generator function for the user.verify(...) method. By default, the system will still use the crypto.randomBytes() method if no option is provided. (jakerella)

 * Remove unnecessary delay in tests. (Miroslav Bajtoš)

 * Update README.md (Simon Ho)

 * Remove duplicate cb func from getRoles and other doc cleanup (crandmck)

 * Enhance the token middleware to support current user literal (Raymond Feng)

 * Handling owner being a relation/function (Benjamin Boudreau)

 * Run replication tests in the browser too (Miroslav Bajtoš)

 * Add replication tests for conflict resolution (Miroslav Bajtoš)

 * Fix an assertion broke by recent chai upgrade. (Miroslav Bajtoš)

 * Static ACL support array of properties now (ulion)

 * Add more integration tests for replication (Miroslav Bajtoš)

 * Prevent more kinds of false replication conflicts (Miroslav Bajtoš)

 * Upgrade deps (Raymond Feng)

 * Fix "Issues" link in readme (Simon Ho)

 * Add more debug logs to replication (Miroslav Bajtoš)

 * Fixes #1158. (Jason Sturges)

 * Checkpoint: start with seq=1 instead of seq=0 (Miroslav Bajtoš)

 * Return new checkpoints in callback of replicate() (Miroslav Bajtoš)

 * Create a remote checkpoint during replication too (Miroslav Bajtoš)

 * Replication: fix checkpoint-related race condition (Miroslav Bajtoš)

 * Support different "since" for source and target (Miroslav Bajtoš)
2015-04-01 18:50:18 +02:00
Miroslav Bajtoš 4a81d06018 Merge pull request #1251 from strongloop/feature/improve-replication-error-logging
Improve error handling in replication
2015-03-30 11:16:54 +02:00
Miroslav Bajtoš 63e2f4b134 Improve error handling in replication
Deprecate `Change.handleError`, it was used inconsistenly for a subset
of possible errors only. Rework all `Change` methods to always report
all errors to the caller via the callback.

Rework `PersistedModel` to report change-tracking errors via the
existing method `PersistedModel.handleChangeError`. This method
can be customized on a per-model basis to provide different error
handling.

The default implementation emits `error` event on the model class,
users can attach an event listener that can provide a custom error
handler.

NOTE: Unhandled `error` events crash the application by default.
2015-03-30 11:07:53 +02:00
Miroslav Bajtoš 6640f8a082 Merge pull request #1254 from strongloop/feature/run-in-context
Add `loopback.runInContext`
2015-03-27 19:15:22 +01:00
Miroslav Bajtoš 2aa09ba574 Add `loopback.runInContext`
Refactor the core implementation of current context from
server/middleware/context.js into server/current-context.js.

Expose new public API:
 - loopback.runInContext
 - loopback.createContext
2015-03-27 19:12:17 +01:00