Skip to content

Commit 79f8369

Browse files
author
Vlad Balin
committed
Added ioMethod option. Hidden internal members.
1 parent 2880d4c commit 79f8369

39 files changed

+148
-159
lines changed

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/chapters/io.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Record and Collection has a portion of common API related to the I/O and seriali
269269
270270
### obj.toJSON( options? )
271271
272-
Serialize record or collection to JSON. Used internally by I/O methods. Can be overridden to customize serialization.
272+
Serialize record or collection to JSON. Used internally by `save()` I/O method (`options.ioMethod === 'save'` when called from within `save()`). Can be overridden to customize serialization.
273273
274274
Produces the JSON for the given record or collection and its aggregated members. Aggregation tree is serialized as nested JSON. Record corresponds to an object in JSON, while the collection is represented as an array of objects.
275275
@@ -314,9 +314,9 @@ const book = new Book();
314314
book.set( bestSeller.toJSON(), { parse : true } );
315315
```
316316
317-
### `callback` obj.parse( json )
317+
### `callback` obj.parse( json, options? )
318318
319-
Optional hook called to transform the JSON when it's passes to the record or collection with `set( json, { parse : true })` call. Used internally by I/O methods.
319+
Optional hook called to transform the JSON when it's passes to the record or collection with `set( json, { parse : true })` call. Used internally by I/O methods (`options.ioMethod` is either "save" or "fetch" when called from I/O method).
320320
321321
If you override `toJSON()`, it usually means that you must override `parse()` as well, and vice versa.
322322

docs/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ <h3 id="createiopromise-init-">createIOPromise( init )</h3>
16701670
<h2 id="serialization">Serialization</h2>
16711671
<p>Record and Collection has a portion of common API related to the I/O and serialization.</p>
16721672
<h3 id="obj-tojson-options-">obj.toJSON( options? )</h3>
1673-
<p>Serialize record or collection to JSON. Used internally by I/O methods. Can be overridden to customize serialization.</p>
1673+
<p>Serialize record or collection to JSON. Used internally by <code>save()</code> I/O method (<code>options.ioMethod === &#39;save&#39;</code> when called from within <code>save()</code>). Can be overridden to customize serialization.</p>
16741674
<p>Produces the JSON for the given record or collection and its aggregated members. Aggregation tree is serialized as nested JSON. Record corresponds to an object in JSON, while the collection is represented as an array of objects.</p>
16751675
<p>If you override <code>toJSON()</code>, it usually means that you must override <code>parse()</code> as well, and vice versa.</p>
16761676
<aside class="notice">
@@ -1706,8 +1706,8 @@ <h3 id="option-parse-true-"><code>option</code> { parse : true }</h3>
17061706
<span class="hljs-keyword">const</span> book = <span class="hljs-keyword">new</span> Book();
17071707
book.set( bestSeller.toJSON(), { <span class="hljs-attr">parse</span> : <span class="hljs-literal">true</span> } );
17081708
</code></pre>
1709-
<h3 id="callback-obj-parse-json-"><code>callback</code> obj.parse( json )</h3>
1710-
<p>Optional hook called to transform the JSON when it&#39;s passes to the record or collection with <code>set( json, { parse : true })</code> call. Used internally by I/O methods.</p>
1709+
<h3 id="callback-obj-parse-json-options-"><code>callback</code> obj.parse( json, options? )</h3>
1710+
<p>Optional hook called to transform the JSON when it&#39;s passes to the record or collection with <code>set( json, { parse : true })</code> call. Used internally by I/O methods (<code>options.ioMethod</code> is either &quot;save&quot; or &quot;fetch&quot; when called from I/O method).</p>
17111711
<p>If you override <code>toJSON()</code>, it usually means that you must override <code>parse()</code> as well, and vice versa.</p>
17121712
<aside class="notice">
17131713
Parsing can be controlled on per-attribute level with <b>type( Type ).parse()</b> declaration.

endpoints/proxy/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

endpoints/proxy/lib/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface ProxyIOInternalOptions {
1010
}
1111
export declare class ProxyEndpoint implements IOEndpoint {
1212
Record: typeof Record;
13-
readonly endpoint: IOEndpoint;
13+
readonly endpoint: any;
1414
options: ProxyIOInternalOptions;
1515
constructor(record: typeof Record, options?: ProxyIOOptions);
1616
subscribe(events: any, target: any): Promise<any>;

endpoints/proxy/lib/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

endpoints/proxy/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface ProxyIOInternalOptions {
2020
export class ProxyEndpoint implements IOEndpoint {
2121
Record : typeof Record
2222
get endpoint(){
23-
return this.Record.prototype._endpoint;
23+
return ( this.Record.prototype as any )._endpoint;
2424
}
2525

2626
options : ProxyIOInternalOptions = {}

lib/collection/commons.d.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import { eventsApi, Logger } from '../object-plus';
21
import { Record } from '../record';
32
import { Owner, Transaction, Transactional, TransactionOptions } from '../transactions';
43
export interface CollectionCore extends Transactional, Owner {
5-
_byId: IdIndex;
64
models: Record[];
75
model: typeof Record;
86
idAttribute: string;
9-
_comparator: Comparator;
107
get(objOrId: string | Record | Object): Record;
11-
_itemEvents?: eventsApi.EventMap;
12-
_shared: number;
13-
_aggregationError: Record[];
14-
_log(level: string, topic: string, text: string, value: any, logger: Logger): void;
158
}
169
export declare type Elements = (Object | Record)[];
1710
export interface CollectionOptions extends TransactionOptions {

0 commit comments

Comments
 (0)