nylas 5.8.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.
Files changed (79) hide show
  1. package/LICENSE.txt +22 -0
  2. package/README.md +65 -0
  3. package/lib/config.d.ts +4 -0
  4. package/lib/config.js +13 -0
  5. package/lib/models/account.d.ts +10 -0
  6. package/lib/models/account.js +61 -0
  7. package/lib/models/attributes.d.ts +104 -0
  8. package/lib/models/attributes.js +266 -0
  9. package/lib/models/calendar-restful-model-collection.d.ts +76 -0
  10. package/lib/models/calendar-restful-model-collection.js +128 -0
  11. package/lib/models/calendar.d.ts +19 -0
  12. package/lib/models/calendar.js +81 -0
  13. package/lib/models/connect.d.ts +12 -0
  14. package/lib/models/connect.js +51 -0
  15. package/lib/models/contact-restful-model-collection.d.ts +11 -0
  16. package/lib/models/contact-restful-model-collection.js +54 -0
  17. package/lib/models/contact.d.ts +75 -0
  18. package/lib/models/contact.js +245 -0
  19. package/lib/models/delta-stream.d.ts +30 -0
  20. package/lib/models/delta-stream.js +225 -0
  21. package/lib/models/delta.d.ts +11 -0
  22. package/lib/models/delta.js +91 -0
  23. package/lib/models/draft.d.ts +24 -0
  24. package/lib/models/draft.js +145 -0
  25. package/lib/models/email-participant.d.ts +6 -0
  26. package/lib/models/email-participant.js +44 -0
  27. package/lib/models/event-conferencing.d.ts +24 -0
  28. package/lib/models/event-conferencing.js +84 -0
  29. package/lib/models/event-participant.d.ts +7 -0
  30. package/lib/models/event-participant.js +47 -0
  31. package/lib/models/event.d.ts +45 -0
  32. package/lib/models/event.js +206 -0
  33. package/lib/models/file.d.ts +18 -0
  34. package/lib/models/file.js +151 -0
  35. package/lib/models/folder.d.ts +14 -0
  36. package/lib/models/folder.js +70 -0
  37. package/lib/models/job-status.d.ts +7 -0
  38. package/lib/models/job-status.js +51 -0
  39. package/lib/models/management-account.d.ts +14 -0
  40. package/lib/models/management-account.js +101 -0
  41. package/lib/models/management-model-collection.d.ts +11 -0
  42. package/lib/models/management-model-collection.js +35 -0
  43. package/lib/models/management-model.d.ts +8 -0
  44. package/lib/models/management-model.js +29 -0
  45. package/lib/models/message.d.ts +32 -0
  46. package/lib/models/message.js +154 -0
  47. package/lib/models/neural-categorizer.d.ts +18 -0
  48. package/lib/models/neural-categorizer.js +140 -0
  49. package/lib/models/neural-clean-conversation.d.ts +7 -0
  50. package/lib/models/neural-clean-conversation.js +110 -0
  51. package/lib/models/neural-ocr.d.ts +5 -0
  52. package/lib/models/neural-ocr.js +46 -0
  53. package/lib/models/neural-sentiment-analysis.d.ts +8 -0
  54. package/lib/models/neural-sentiment-analysis.js +49 -0
  55. package/lib/models/neural-signature-contact.d.ts +37 -0
  56. package/lib/models/neural-signature-contact.js +141 -0
  57. package/lib/models/neural-signature-extraction.d.ts +7 -0
  58. package/lib/models/neural-signature-extraction.js +50 -0
  59. package/lib/models/neural.d.ts +22 -0
  60. package/lib/models/neural.js +124 -0
  61. package/lib/models/nylas-api-error.d.ts +28 -0
  62. package/lib/models/nylas-api-error.js +61 -0
  63. package/lib/models/resource.d.ts +9 -0
  64. package/lib/models/resource.js +59 -0
  65. package/lib/models/restful-model-collection.d.ts +59 -0
  66. package/lib/models/restful-model-collection.js +325 -0
  67. package/lib/models/restful-model-instance.d.ts +11 -0
  68. package/lib/models/restful-model-instance.js +37 -0
  69. package/lib/models/restful-model.d.ts +48 -0
  70. package/lib/models/restful-model.js +153 -0
  71. package/lib/models/thread.d.ts +30 -0
  72. package/lib/models/thread.js +112 -0
  73. package/lib/models/webhook.d.ts +15 -0
  74. package/lib/models/webhook.js +71 -0
  75. package/lib/nylas-connection.d.ts +67 -0
  76. package/lib/nylas-connection.js +235 -0
  77. package/lib/nylas.d.ts +38 -0
  78. package/lib/nylas.js +178 -0
  79. package/package.json +76 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+ ----
3
+
4
+ Copyright (c) 2014-2015 InboxApp, Inc. and Contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Nylas Node.js SDK
2
+
3
+ [![Travis build status](https://travis-ci.org/nylas/nylas-nodejs.svg?branch=master)](https://travis-ci.org/nylas/nylas-nodejs)
4
+
5
+ This is the GitHub repository for the Nylas Node SDK and this repo is primarily for anyone who wants to make contributions to the SDK or install it from source. If you are looking to use Node to access the Nylas Email, Calendar, or Contacts API you should refer to our official [Node SDK Quickstart Guide](https://developer.nylas.com/docs/developer-tools/sdk/node-sdk/).
6
+
7
+ The Nylas Communications Platform provides REST APIs for [Email](https://developer.nylas.com/docs/connectivity/email/), [Calendar](https://developer.nylas.com/docs/connectivity/calendar/), and [Contacts](https://developer.nylas.com/docs/connectivity/contacts/), and the Node SDK is the quickest way to build your integration using JavaScript.
8
+
9
+ Here are some resources to help you get started:
10
+
11
+ - [Nylas SDK Tutorials](https://developer.nylas.com/docs/the-basics/tutorials/nodejs/)
12
+ - [Quickstart](https://developer.nylas.com/docs/the-basics/quickstart/)
13
+ - [Nylas API Reference](https://developer.nylas.com/docs/api/)
14
+
15
+
16
+ # Install
17
+
18
+ To run the Nylas Node SDK, you will first need to have [Node](https://nodejs.org/en/download/) and [npm](https://www.npmjs.com/get-npm) installed on your machine.
19
+
20
+ Then, head to the nearest command line and run the following:
21
+ `npm install nylas`
22
+
23
+ Alternatively, if you prefer to use [Yarn](https://yarnpkg.com/en/), you can install the Nylas Node SDK with `yarn add nylas`
24
+
25
+ To install this package from source, clone this repo and run `npm install` from inside the project directory.
26
+
27
+ ```bash
28
+ git clone https://github.com/nylas/nylas-nodejs.git
29
+ cd nylas-nodejs
30
+ npm install
31
+ ```
32
+
33
+ # Usage
34
+
35
+ Every resource (i.e., messages, events, contacts) is accessed via an instance of `Nylas`. Before making any requests, be sure to call `config` and initialize the `Nylas` instance with your `clientId` and `clientSecret`. Then, call `with` and pass it your `accessToken`. The `accessToken` allows `Nylas` to make requests for a given account's resources.
36
+
37
+ ```javascript
38
+ const Nylas = require('nylas');
39
+
40
+ Nylas.config({
41
+ clientId: CLIENT_ID,
42
+ clientSecret: CLIENT_SECRET,
43
+ });
44
+
45
+ const nylas = Nylas.with(ACCESS_TOKEN);
46
+ ```
47
+
48
+ Then, you can use Nylas to access information about a user's account:
49
+ ```javascript
50
+ nylas.threads.list({}).then(threads => {
51
+ console.log(threads.length);
52
+ });
53
+ ```
54
+
55
+ For more information about how to use the Nylas Node SDK, [take a look at our quickstart guide](https://developer.nylas.com/docs/developer-tools/sdk/node-sdk/).
56
+
57
+ # Contributing
58
+
59
+ Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.
60
+
61
+ # License
62
+
63
+ This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.
64
+
65
+
@@ -0,0 +1,4 @@
1
+ export declare let apiServer: string | null;
2
+ export declare function setApiServer(newApiServer: string | null): void;
3
+ export declare let clientSecret: string;
4
+ export declare function setClientSecret(newClientSecret: string): void;
package/lib/config.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setClientSecret = exports.clientSecret = exports.setApiServer = exports.apiServer = void 0;
4
+ exports.apiServer = null;
5
+ function setApiServer(newApiServer) {
6
+ exports.apiServer = newApiServer;
7
+ }
8
+ exports.setApiServer = setApiServer;
9
+ exports.clientSecret = '';
10
+ function setClientSecret(newClientSecret) {
11
+ exports.clientSecret = newClientSecret;
12
+ }
13
+ exports.setClientSecret = setClientSecret;
@@ -0,0 +1,10 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class Account extends RestfulModel {
3
+ name?: string;
4
+ emailAddress?: string;
5
+ provider?: string;
6
+ organizationUnit?: string;
7
+ syncState?: string;
8
+ billingState?: string;
9
+ linkedAt?: Date;
10
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ var restful_model_1 = __importDefault(require("./restful-model"));
31
+ var attributes_1 = __importDefault(require("./attributes"));
32
+ var Account = /** @class */ (function (_super) {
33
+ __extends(Account, _super);
34
+ function Account() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ return Account;
38
+ }(restful_model_1.default));
39
+ exports.default = Account;
40
+ Account.collectionName = 'accounts';
41
+ Account.endpointName = 'account';
42
+ Account.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
43
+ modelKey: 'name',
44
+ }), emailAddress: attributes_1.default.String({
45
+ modelKey: 'emailAddress',
46
+ jsonKey: 'email_address',
47
+ }), provider: attributes_1.default.String({
48
+ modelKey: 'provider',
49
+ }), organizationUnit: attributes_1.default.String({
50
+ modelKey: 'organizationUnit',
51
+ jsonKey: 'organization_unit',
52
+ }), syncState: attributes_1.default.String({
53
+ modelKey: 'syncState',
54
+ jsonKey: 'sync_state',
55
+ }), billingState: attributes_1.default.String({
56
+ modelKey: 'billingState',
57
+ jsonKey: 'billing_state',
58
+ }), linkedAt: attributes_1.default.DateTime({
59
+ modelKey: 'linkedAt',
60
+ jsonKey: 'linked_at',
61
+ }) });
@@ -0,0 +1,104 @@
1
+ import RestfulModel from './restful-model';
2
+ export declare class Attribute {
3
+ modelKey: string;
4
+ jsonKey: string;
5
+ readOnly: boolean;
6
+ constructor({ modelKey, jsonKey, readOnly, }: {
7
+ modelKey: string;
8
+ jsonKey?: string;
9
+ readOnly?: boolean;
10
+ });
11
+ toJSON(val: any): any;
12
+ fromJSON(val: any, _parent: any): any;
13
+ }
14
+ declare class AttributeObject extends Attribute {
15
+ itemClass?: typeof RestfulModel;
16
+ constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
17
+ modelKey: string;
18
+ jsonKey?: string;
19
+ itemClass?: typeof RestfulModel;
20
+ readOnly?: boolean;
21
+ });
22
+ toJSON(val: any): any;
23
+ fromJSON(val: any, _parent: any): any;
24
+ }
25
+ declare class AttributeNumber extends Attribute {
26
+ toJSON(val: any): any;
27
+ fromJSON(val: any, _parent: any): number | null;
28
+ }
29
+ declare class AttributeBoolean extends Attribute {
30
+ toJSON(val: any): any;
31
+ fromJSON(val: any, _parent: any): boolean;
32
+ }
33
+ declare class AttributeString extends Attribute {
34
+ toJSON(val: any): any;
35
+ fromJSON(val: any, _parent: any): any;
36
+ }
37
+ declare class AttributeStringList extends Attribute {
38
+ toJSON(val: any): any;
39
+ fromJSON(val: any, _parent: any): any;
40
+ }
41
+ declare class AttributeDate extends Attribute {
42
+ toJSON(val: any): any;
43
+ fromJSON(val: any, _parent: any): Date | null;
44
+ }
45
+ declare class AttributeDateTime extends Attribute {
46
+ toJSON(val: any): number | null;
47
+ fromJSON(val: any, _parent: any): Date | null;
48
+ }
49
+ declare class AttributeCollection extends Attribute {
50
+ itemClass: typeof RestfulModel;
51
+ constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
52
+ modelKey: string;
53
+ jsonKey?: string;
54
+ itemClass: typeof RestfulModel;
55
+ readOnly?: boolean;
56
+ });
57
+ toJSON(vals: any): any[];
58
+ fromJSON(json: any, _parent: any): RestfulModel[];
59
+ }
60
+ declare const Attributes: {
61
+ Number(__0: {
62
+ modelKey: string;
63
+ jsonKey?: string | undefined;
64
+ readOnly?: boolean | undefined;
65
+ }): AttributeNumber;
66
+ String(__0: {
67
+ modelKey: string;
68
+ jsonKey?: string | undefined;
69
+ readOnly?: boolean | undefined;
70
+ }): AttributeString;
71
+ StringList(__0: {
72
+ modelKey: string;
73
+ jsonKey?: string | undefined;
74
+ readOnly?: boolean | undefined;
75
+ }): AttributeStringList;
76
+ DateTime(__0: {
77
+ modelKey: string;
78
+ jsonKey?: string | undefined;
79
+ readOnly?: boolean | undefined;
80
+ }): AttributeDateTime;
81
+ Date(__0: {
82
+ modelKey: string;
83
+ jsonKey?: string | undefined;
84
+ readOnly?: boolean | undefined;
85
+ }): AttributeDate;
86
+ Collection(__0: {
87
+ modelKey: string;
88
+ jsonKey?: string | undefined;
89
+ itemClass: typeof RestfulModel;
90
+ readOnly?: boolean | undefined;
91
+ }): AttributeCollection;
92
+ Boolean(__0: {
93
+ modelKey: string;
94
+ jsonKey?: string | undefined;
95
+ readOnly?: boolean | undefined;
96
+ }): AttributeBoolean;
97
+ Object(__0: {
98
+ modelKey: string;
99
+ jsonKey?: string | undefined;
100
+ itemClass?: typeof RestfulModel | undefined;
101
+ readOnly?: boolean | undefined;
102
+ }): AttributeObject;
103
+ };
104
+ export default Attributes;
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
16
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
17
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
18
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
19
+ r[k] = a[j];
20
+ return r;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.Attribute = void 0;
24
+ // The Attribute class represents a single model attribute, like 'namespace_id'
25
+ // Subclasses of Attribute like AttributeDateTime know how to covert between
26
+ // the JSON representation of that type and the javascript representation.
27
+ // The Attribute class also exposes convenience methods for generating Matchers.
28
+ var Attribute = /** @class */ (function () {
29
+ function Attribute(_a) {
30
+ var modelKey = _a.modelKey, jsonKey = _a.jsonKey, readOnly = _a.readOnly;
31
+ this.modelKey = modelKey;
32
+ this.jsonKey = jsonKey || modelKey;
33
+ this.readOnly = readOnly || false;
34
+ }
35
+ Attribute.prototype.toJSON = function (val) {
36
+ return val;
37
+ };
38
+ Attribute.prototype.fromJSON = function (val, _parent) {
39
+ return val || null;
40
+ };
41
+ return Attribute;
42
+ }());
43
+ exports.Attribute = Attribute;
44
+ var AttributeObject = /** @class */ (function (_super) {
45
+ __extends(AttributeObject, _super);
46
+ function AttributeObject(_a) {
47
+ var modelKey = _a.modelKey, jsonKey = _a.jsonKey, itemClass = _a.itemClass, readOnly = _a.readOnly;
48
+ var _this = _super.call(this, { modelKey: modelKey, jsonKey: jsonKey, readOnly: readOnly }) || this;
49
+ _this.itemClass = itemClass;
50
+ return _this;
51
+ }
52
+ AttributeObject.prototype.toJSON = function (val) {
53
+ if (!val) {
54
+ return val;
55
+ }
56
+ if (val.toJSON != null) {
57
+ return val.toJSON();
58
+ }
59
+ return val;
60
+ };
61
+ AttributeObject.prototype.fromJSON = function (val, _parent) {
62
+ if (!val || !this.itemClass) {
63
+ return val;
64
+ }
65
+ return new this.itemClass(_parent.connection, val);
66
+ };
67
+ return AttributeObject;
68
+ }(Attribute));
69
+ var AttributeNumber = /** @class */ (function (_super) {
70
+ __extends(AttributeNumber, _super);
71
+ function AttributeNumber() {
72
+ return _super !== null && _super.apply(this, arguments) || this;
73
+ }
74
+ AttributeNumber.prototype.toJSON = function (val) {
75
+ return val;
76
+ };
77
+ AttributeNumber.prototype.fromJSON = function (val, _parent) {
78
+ if (!isNaN(val)) {
79
+ return Number(val);
80
+ }
81
+ else {
82
+ return null;
83
+ }
84
+ };
85
+ return AttributeNumber;
86
+ }(Attribute));
87
+ var AttributeBoolean = /** @class */ (function (_super) {
88
+ __extends(AttributeBoolean, _super);
89
+ function AttributeBoolean() {
90
+ return _super !== null && _super.apply(this, arguments) || this;
91
+ }
92
+ AttributeBoolean.prototype.toJSON = function (val) {
93
+ return val;
94
+ };
95
+ AttributeBoolean.prototype.fromJSON = function (val, _parent) {
96
+ return val === 'true' || val === true || false;
97
+ };
98
+ return AttributeBoolean;
99
+ }(Attribute));
100
+ var AttributeString = /** @class */ (function (_super) {
101
+ __extends(AttributeString, _super);
102
+ function AttributeString() {
103
+ return _super !== null && _super.apply(this, arguments) || this;
104
+ }
105
+ AttributeString.prototype.toJSON = function (val) {
106
+ return val;
107
+ };
108
+ AttributeString.prototype.fromJSON = function (val, _parent) {
109
+ return val || '';
110
+ };
111
+ return AttributeString;
112
+ }(Attribute));
113
+ var AttributeStringList = /** @class */ (function (_super) {
114
+ __extends(AttributeStringList, _super);
115
+ function AttributeStringList() {
116
+ return _super !== null && _super.apply(this, arguments) || this;
117
+ }
118
+ AttributeStringList.prototype.toJSON = function (val) {
119
+ return val;
120
+ };
121
+ AttributeStringList.prototype.fromJSON = function (val, _parent) {
122
+ return val || [];
123
+ };
124
+ return AttributeStringList;
125
+ }(Attribute));
126
+ var AttributeDate = /** @class */ (function (_super) {
127
+ __extends(AttributeDate, _super);
128
+ function AttributeDate() {
129
+ return _super !== null && _super.apply(this, arguments) || this;
130
+ }
131
+ AttributeDate.prototype.toJSON = function (val) {
132
+ if (!val) {
133
+ return val;
134
+ }
135
+ if (!(val instanceof Date)) {
136
+ throw new Error("Attempting to toJSON AttributeDate which is not a date:\n " + this.modelKey + "\n = " + val);
137
+ }
138
+ return val.toISOString();
139
+ };
140
+ AttributeDate.prototype.fromJSON = function (val, _parent) {
141
+ if (!val) {
142
+ return null;
143
+ }
144
+ return new Date(val);
145
+ };
146
+ return AttributeDate;
147
+ }(Attribute));
148
+ var AttributeDateTime = /** @class */ (function (_super) {
149
+ __extends(AttributeDateTime, _super);
150
+ function AttributeDateTime() {
151
+ return _super !== null && _super.apply(this, arguments) || this;
152
+ }
153
+ AttributeDateTime.prototype.toJSON = function (val) {
154
+ if (!val) {
155
+ return null;
156
+ }
157
+ if (!(val instanceof Date)) {
158
+ throw new Error("Attempting to toJSON AttributeDateTime which is not a date:\n " + this.modelKey + "\n = " + val);
159
+ }
160
+ return val.getTime() / 1000.0;
161
+ };
162
+ AttributeDateTime.prototype.fromJSON = function (val, _parent) {
163
+ if (!val) {
164
+ return null;
165
+ }
166
+ return new Date(val * 1000);
167
+ };
168
+ return AttributeDateTime;
169
+ }(Attribute));
170
+ var AttributeCollection = /** @class */ (function (_super) {
171
+ __extends(AttributeCollection, _super);
172
+ function AttributeCollection(_a) {
173
+ var modelKey = _a.modelKey, jsonKey = _a.jsonKey, itemClass = _a.itemClass, readOnly = _a.readOnly;
174
+ var _this = _super.call(this, { modelKey: modelKey, jsonKey: jsonKey, readOnly: readOnly }) || this;
175
+ _this.itemClass = itemClass;
176
+ return _this;
177
+ }
178
+ AttributeCollection.prototype.toJSON = function (vals) {
179
+ if (!vals) {
180
+ return [];
181
+ }
182
+ var json = [];
183
+ for (var _i = 0, vals_1 = vals; _i < vals_1.length; _i++) {
184
+ var val = vals_1[_i];
185
+ if (val.toJSON != null) {
186
+ json.push(val.toJSON());
187
+ }
188
+ else {
189
+ json.push(val);
190
+ }
191
+ }
192
+ return json;
193
+ };
194
+ AttributeCollection.prototype.fromJSON = function (json, _parent) {
195
+ if (!json || !(json instanceof Array)) {
196
+ return [];
197
+ }
198
+ var objs = [];
199
+ for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
200
+ var objJSON = json_1[_i];
201
+ var obj = new this.itemClass(_parent.connection, objJSON);
202
+ objs.push(obj);
203
+ }
204
+ return objs;
205
+ };
206
+ return AttributeCollection;
207
+ }(Attribute));
208
+ var Attributes = {
209
+ Number: function () {
210
+ var args = [];
211
+ for (var _i = 0; _i < arguments.length; _i++) {
212
+ args[_i] = arguments[_i];
213
+ }
214
+ return new (AttributeNumber.bind.apply(AttributeNumber, __spreadArrays([void 0], args)))();
215
+ },
216
+ String: function () {
217
+ var args = [];
218
+ for (var _i = 0; _i < arguments.length; _i++) {
219
+ args[_i] = arguments[_i];
220
+ }
221
+ return new (AttributeString.bind.apply(AttributeString, __spreadArrays([void 0], args)))();
222
+ },
223
+ StringList: function () {
224
+ var args = [];
225
+ for (var _i = 0; _i < arguments.length; _i++) {
226
+ args[_i] = arguments[_i];
227
+ }
228
+ return new (AttributeStringList.bind.apply(AttributeStringList, __spreadArrays([void 0], args)))();
229
+ },
230
+ DateTime: function () {
231
+ var args = [];
232
+ for (var _i = 0; _i < arguments.length; _i++) {
233
+ args[_i] = arguments[_i];
234
+ }
235
+ return new (AttributeDateTime.bind.apply(AttributeDateTime, __spreadArrays([void 0], args)))();
236
+ },
237
+ Date: function () {
238
+ var args = [];
239
+ for (var _i = 0; _i < arguments.length; _i++) {
240
+ args[_i] = arguments[_i];
241
+ }
242
+ return new (AttributeDate.bind.apply(AttributeDate, __spreadArrays([void 0], args)))();
243
+ },
244
+ Collection: function () {
245
+ var args = [];
246
+ for (var _i = 0; _i < arguments.length; _i++) {
247
+ args[_i] = arguments[_i];
248
+ }
249
+ return new (AttributeCollection.bind.apply(AttributeCollection, __spreadArrays([void 0], args)))();
250
+ },
251
+ Boolean: function () {
252
+ var args = [];
253
+ for (var _i = 0; _i < arguments.length; _i++) {
254
+ args[_i] = arguments[_i];
255
+ }
256
+ return new (AttributeBoolean.bind.apply(AttributeBoolean, __spreadArrays([void 0], args)))();
257
+ },
258
+ Object: function () {
259
+ var args = [];
260
+ for (var _i = 0; _i < arguments.length; _i++) {
261
+ args[_i] = arguments[_i];
262
+ }
263
+ return new (AttributeObject.bind.apply(AttributeObject, __spreadArrays([void 0], args)))();
264
+ },
265
+ };
266
+ exports.default = Attributes;