Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions doc/7/core-classes/profile/serialize/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
code: true
type: page
title: serialize
description: Profile serialize method
---

# serialize

<SinceBadge version="7.6.2" />

Serialize the profile into a JSONObject.

## Arguments

```js
serialize();
```

## Resolve

Serialized profile with the following properties:
- `_id`: Profile ID
- `rateLimit`: Profile rate limits
- `policies`: Profile policies
24 changes: 24 additions & 0 deletions doc/7/core-classes/role/serialize/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
code: true
type: page
title: serialize
description: Role serialize method
---

# serialize

<SinceBadge version="7.6.2" />

Serialize the profile into a JSONObject.

## Arguments

```js
serialize();
```

## Resolve

Serialized role with the following properties:
- `_id`: Role ID
- `controllers`: Controllers definition
24 changes: 24 additions & 0 deletions doc/7/core-classes/user/serialize/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
code: true
type: page
title: serialize
description: User serialize method
---

# serialize

<SinceBadge version="7.6.2" />

Serialize the user into a JSONObject.

## Arguments

```js
serialize();
```

## Resolve

Serialized user with the following properties:
- `_id`: User ID
- `_source`: User content
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "7.6.1",
"version": "7.6.2",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <[email protected]>",
"repository": {
Expand Down
16 changes: 11 additions & 5 deletions src/controllers/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export class DocumentController extends BaseController {
* - `queuable` If true, queues the request during downtime, until connected to Kuzzle again
* - `refresh` If set to `wait_for`, Kuzzle will not respond until the API key is indexed
* - `silent` If true, then Kuzzle will not generate notifications
* - `strict` If true, an error will occur if a document was not created
*
* @returns An object containing 2 arrays: "successes" and "errors"
*/
Expand All @@ -279,7 +280,7 @@ export class DocumentController extends BaseController {
*/
body: JSONObject;
}>,
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean } = {}
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean, strict?: boolean } = {}
): Promise<{
/**
* Array of successfully created documents
Expand Down Expand Up @@ -327,6 +328,7 @@ export class DocumentController extends BaseController {
* - `queuable` If true, queues the request during downtime, until connected to Kuzzle again
* - `refresh` If set to `wait_for`, Kuzzle will not respond until the API key is indexed
* - `silent` If true, then Kuzzle will not generate notifications
* - `strict` If true, an error will occur if a document was not created
*
* @returns An object containing 2 arrays: "successes" and "errors"
*/
Expand All @@ -343,7 +345,7 @@ export class DocumentController extends BaseController {
*/
body: JSONObject;
}>,
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean } = {}
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean, strict?: boolean } = {}
): Promise<{
/**
* Array of successfully created documents
Expand Down Expand Up @@ -391,14 +393,15 @@ export class DocumentController extends BaseController {
* - `queuable` If true, queues the request during downtime, until connected to Kuzzle again
* - `refresh` If set to `wait_for`, Kuzzle will not respond until the API key is indexed
* - `silent` If true, then Kuzzle will not generate notifications
* - `strict` If true, an error will occur if a document was not deleted
*
* @returns An object containing 2 arrays: "successes" and "errors"
*/
mDelete (
index: string,
collection: string,
ids: Array<string>,
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean } = {}
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean, strict?: boolean } = {}
): Promise<{
/**
* Array of successfully deleted documents IDS
Expand Down Expand Up @@ -482,6 +485,7 @@ export class DocumentController extends BaseController {
* - `queuable` If true, queues the request during downtime, until connected to Kuzzle again
* - `refresh` If set to `wait_for`, Kuzzle will not respond until the API key is indexed
* - `silent` If true, then Kuzzle will not generate notifications
* - `strict` If true, an error will occur if a document was not replaced
*
* @returns An object containing 2 arrays: "successes" and "errors"
*/
Expand All @@ -498,7 +502,7 @@ export class DocumentController extends BaseController {
*/
body: JSONObject;
}>,
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean } = {}
options: { queuable?: boolean, refresh?: 'wait_for', silent?: boolean, strict?: boolean } = {}
): Promise<{
/**
* Array of successfully replaced documents
Expand Down Expand Up @@ -550,6 +554,7 @@ export class DocumentController extends BaseController {
* - `refresh` If set to `wait_for`, Kuzzle will not respond until the API key is indexed
* - `silent` If true, then Kuzzle will not generate notifications
* - `retryOnConflict` Number of times the database layer should retry in case of version conflict
* - `strict` If true, an error will occur if a document was not updated
*
* @returns An object containing 2 arrays: "successes" and "errors"
*/
Expand All @@ -570,7 +575,8 @@ export class DocumentController extends BaseController {
queuable?: boolean,
refresh?: 'wait_for',
silent?: boolean,
retryOnConflict?: number
retryOnConflict?: number,
strict?: boolean,
} = {}
): Promise<{
/**
Expand Down
20 changes: 15 additions & 5 deletions src/core/security/Profile.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { Role } from './Role';
import { ProfilePolicy } from '../../types';
import { JSONObject, ProfilePolicy } from '../../types';

export class Profile {
/**
* Profile unique ID
*/
public _id: string;
_id: string;

/**
* Maximum number of requests per second and per node with this profile
*/
public rateLimit: number;
rateLimit: number;

/**
* Array of policies
*/
public policies: Array<ProfilePolicy>;

policies: Array<ProfilePolicy>;

private _kuzzle: any;

Expand Down Expand Up @@ -51,4 +50,15 @@ export class Profile {
this.policies.map(policy => policy.roleId),
options);
}

/**
* Serialize the instance
*/
serialize (): JSONObject {
return {
_id: this._id,
rateLimit: this.rateLimit,
policies: this.policies,
};
}
}
17 changes: 14 additions & 3 deletions src/core/security/Role.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { RoleRightsDefinition } from '../../types';
import { JSONObject, RoleRightsDefinition } from '../../types';

export class Role {
/**
* Role unique ID
*/
public _id: string;
_id: string;

/**
* List of rights on controllers/actions
*/
public controllers: RoleRightsDefinition;
controllers: RoleRightsDefinition;

private _kuzzle: any;

Expand All @@ -28,6 +29,16 @@ export class Role {
protected get kuzzle () {
return this._kuzzle;
}

/**
* Serialize the instance
*/
serialize (): JSONObject {
return {
_id: this._id,
controllers: this.controllers,
};
}
}

module.exports = { Role };
Expand Down
26 changes: 20 additions & 6 deletions src/core/security/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ export class User {
/**
* Kuid (Kuzzle unique ID)
*/
public _id: string;
_id: string;

/**
* User content
*/
public _source: JSONObject;
_source: JSONObject;

/**
* User content
*
* @deprecated
* @deprecated Use User._source instead
*/
get content (): JSONObject {
return this._source;
}
content: JSONObject

private _kuzzle: any;

Expand All @@ -33,6 +31,13 @@ export class User {
value: kuzzle
});

Reflect.defineProperty(this, 'content', {
enumerable: true,
get () {
return this._source;
}
});

this._id = _id;
this._source = content;
}
Expand All @@ -59,6 +64,15 @@ export class User {
return this.kuzzle.security.mGetProfiles(this.profileIds);
}

/**
* Serialize the instance
*/
serialize (): JSONObject {
return {
_id: this._id,
_source: this._source,
};
}
}

module.exports = { User };
Expand Down