gingersnap 0.23.11 → 0.23.13
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/data/model/model.cjs +180 -138
- package/data/model/model.d.ts +64 -43
- package/data/model/model.mjs +180 -138
- package/data/model/property.cjs +32 -2
- package/data/model/property.d.ts +5 -1
- package/data/model/property.mjs +32 -3
- package/data/model.cjs +1 -0
- package/data/model.mjs +1 -1
- package/data/store/manager.cjs +3 -3
- package/data/store/manager.mjs +3 -3
- package/networking/EventSourceService.cjs +1 -1
- package/networking/EventSourceService.mjs +1 -1
- package/package.json +1 -1
package/data/model/model.d.ts
CHANGED
|
@@ -23,10 +23,12 @@ export interface FieldProps {
|
|
|
23
23
|
Type: any;
|
|
24
24
|
KeyType?: any;
|
|
25
25
|
ValueType?: any;
|
|
26
|
+
isUnion?: boolean;
|
|
26
27
|
isArray?: boolean;
|
|
27
28
|
isMap?: boolean;
|
|
28
29
|
readonly?: boolean;
|
|
29
30
|
aliases?: string[];
|
|
31
|
+
unionTypes?: any[];
|
|
30
32
|
schema?: {
|
|
31
33
|
description: string;
|
|
32
34
|
dataType: DataType;
|
|
@@ -78,6 +80,26 @@ export declare class Optional<T> {
|
|
|
78
80
|
*/
|
|
79
81
|
get(): T;
|
|
80
82
|
}
|
|
83
|
+
export interface ModelConversionOptions {
|
|
84
|
+
array?: boolean;
|
|
85
|
+
maybeArray?: boolean;
|
|
86
|
+
format?: DataFormat;
|
|
87
|
+
}
|
|
88
|
+
export interface ModelAdvanceConversionOptions extends ModelConversionOptions {
|
|
89
|
+
headers?: string[];
|
|
90
|
+
ignoreErrors?: boolean;
|
|
91
|
+
delimiter?: string;
|
|
92
|
+
newline?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ModelURLConversionOptions extends ModelAdvanceConversionOptions {
|
|
95
|
+
requestHeaders?: any;
|
|
96
|
+
mode?: any;
|
|
97
|
+
}
|
|
98
|
+
export interface ModelExportOptions {
|
|
99
|
+
removeMissingFields?: boolean;
|
|
100
|
+
keepOptionals?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export type ModelJSONConversionOptions = Omit<ModelConversionOptions, "format">;
|
|
81
103
|
/**
|
|
82
104
|
* A Data de/serializer class that manages and validates data as JavaScript Objects
|
|
83
105
|
*/
|
|
@@ -87,46 +109,42 @@ export declare class Model {
|
|
|
87
109
|
/**
|
|
88
110
|
* Converts arraybuffer to a model
|
|
89
111
|
* @param data arraybuffer
|
|
90
|
-
* @param format data format
|
|
91
112
|
* @param options configurations for deserializing the data
|
|
92
113
|
* @returns new model or an array of models
|
|
93
114
|
*/
|
|
94
|
-
static fromBuffer<T extends Model>(this: ModelConstructor<T>, data: Uint8Array | Buffer,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
115
|
+
static fromBuffer<T extends Model>(this: ModelConstructor<T>, data: Uint8Array | Buffer, options?: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray">): T;
|
|
116
|
+
static fromBuffer<T extends Model>(this: ModelConstructor<T>, data: Uint8Array | Buffer, options: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray"> & {
|
|
117
|
+
array: true;
|
|
118
|
+
}): T[];
|
|
119
|
+
static fromBuffer<T extends Model>(this: ModelConstructor<T>, data: Uint8Array | Buffer, options: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray"> & {
|
|
120
|
+
maybeArray: true;
|
|
100
121
|
}): T | T[];
|
|
122
|
+
static fromBuffer<T extends Model>(this: ModelConstructor<T>, data: Uint8Array | Buffer, options?: ModelAdvanceConversionOptions): T | T[];
|
|
101
123
|
/**
|
|
102
124
|
* Downloads data from the given source and deserializes the data to one or more models
|
|
103
125
|
* @param source URL source to fetch the data
|
|
104
|
-
* @param format data format
|
|
105
126
|
* @param options configurations for deserializing and/or retrieving the data
|
|
106
127
|
* @returns one or more models
|
|
107
128
|
*/
|
|
108
|
-
static fromURL<T extends Model>(this: ModelConstructor<T>, source: string,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
requestHeaders?: any;
|
|
115
|
-
mode?: any;
|
|
129
|
+
static fromURL<T extends Model>(this: ModelConstructor<T>, source: string, options?: Omit<ModelURLConversionOptions, "array" | "maybeArray">): Promise<T>;
|
|
130
|
+
static fromURL<T extends Model>(this: ModelConstructor<T>, source: string, options: Omit<ModelURLConversionOptions, "array" | "maybeArray"> & {
|
|
131
|
+
array: true;
|
|
132
|
+
}): Promise<T[]>;
|
|
133
|
+
static fromURL<T extends Model>(this: ModelConstructor<T>, source: string, options: Omit<ModelURLConversionOptions, "array" | "maybeArray"> & {
|
|
134
|
+
maybeArray: true;
|
|
116
135
|
}): Promise<T | T[]>;
|
|
117
136
|
/**
|
|
118
137
|
* Deserializes one or more models from a Blob
|
|
119
138
|
* @param data blob data
|
|
120
|
-
* @param format data format
|
|
121
139
|
* @param options configurations for deserializing the data
|
|
122
140
|
* @returns one or more models
|
|
123
141
|
*/
|
|
124
|
-
static fromBlob<T extends Model>(this: ModelConstructor<T>, data: Blob,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
static fromBlob<T extends Model>(this: ModelConstructor<T>, data: Blob, options?: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray">): Promise<T>;
|
|
143
|
+
static fromBlob<T extends Model>(this: ModelConstructor<T>, data: Blob, options: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray"> & {
|
|
144
|
+
array: true;
|
|
145
|
+
}): Promise<T[]>;
|
|
146
|
+
static fromBlob<T extends Model>(this: ModelConstructor<T>, data: Blob, options: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray"> & {
|
|
147
|
+
maybeArray: true;
|
|
130
148
|
}): Promise<T | T[]>;
|
|
131
149
|
/**
|
|
132
150
|
* Deserializes one or more models from given string
|
|
@@ -134,15 +152,14 @@ export declare class Model {
|
|
|
134
152
|
* @remarks
|
|
135
153
|
* If the data format is a binary one, the provided string should be a hexadecimal string.
|
|
136
154
|
* @param data string data source
|
|
137
|
-
* @param format data format
|
|
138
155
|
* @param options
|
|
139
156
|
*/
|
|
140
|
-
static fromString<T extends Model>(this: ModelConstructor<T>, data: string,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
157
|
+
static fromString<T extends Model>(this: ModelConstructor<T>, data: string, options?: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray">): T;
|
|
158
|
+
static fromString<T extends Model>(this: ModelConstructor<T>, data: string, options: Omit<ModelAdvanceConversionOptions, "array" | "maybeArray"> & {
|
|
159
|
+
array: true;
|
|
160
|
+
}): T[];
|
|
161
|
+
static fromString<T extends Model>(this: ModelConstructor<T>, data: string, options: Omit<ModelAdvanceConversionOptions, "maybeArray"> & {
|
|
162
|
+
maybeArray: true;
|
|
146
163
|
}): T | T[];
|
|
147
164
|
/**
|
|
148
165
|
* Converts a JSON object to a model
|
|
@@ -150,47 +167,51 @@ export declare class Model {
|
|
|
150
167
|
* @returns new model
|
|
151
168
|
*/
|
|
152
169
|
static fromJSON<T extends Model>(this: ModelConstructor<T>, data: object): T;
|
|
170
|
+
static fromJSON<T extends Model>(this: ModelConstructor<T>, data: object, options: {
|
|
171
|
+
array: true;
|
|
172
|
+
}): T[];
|
|
173
|
+
static fromJSON<T extends Model>(this: ModelConstructor<T>, data: object, options: ModelJSONConversionOptions): T | T[];
|
|
153
174
|
/**
|
|
154
175
|
* Converts the current model to a JSON object
|
|
155
176
|
*/
|
|
156
|
-
object(
|
|
177
|
+
object(options?: ModelExportOptions): {
|
|
157
178
|
[string: string]: any;
|
|
158
179
|
};
|
|
159
180
|
/**
|
|
160
181
|
* Converts the current model to a JSON string
|
|
161
182
|
*/
|
|
162
|
-
json(
|
|
183
|
+
json(options?: ModelExportOptions): string;
|
|
163
184
|
/**
|
|
164
185
|
* Converts the current model to an arraybuffer
|
|
165
186
|
*/
|
|
166
|
-
buffer(
|
|
187
|
+
buffer(options?: ModelExportOptions): ArrayBuffer;
|
|
167
188
|
/**
|
|
168
189
|
* Converts the current model to a blob
|
|
169
190
|
*/
|
|
170
|
-
blob(
|
|
191
|
+
blob(options?: ModelExportOptions): Blob;
|
|
171
192
|
/**
|
|
172
193
|
* Converts the current model to an XML string
|
|
173
194
|
*/
|
|
174
|
-
xml(
|
|
195
|
+
xml(options?: ModelExportOptions): string;
|
|
175
196
|
/**
|
|
176
197
|
* Converts the current model to message pack binary format
|
|
177
198
|
* @returns message pack binary
|
|
178
199
|
*/
|
|
179
|
-
messagePack(
|
|
200
|
+
messagePack(options?: ModelExportOptions): Buffer;
|
|
180
201
|
/**
|
|
181
202
|
* Converts the current model to csv format
|
|
182
|
-
* @param
|
|
203
|
+
* @param options
|
|
183
204
|
* @param config CSV unparsing configuration
|
|
184
205
|
* @returns csv string
|
|
185
206
|
*/
|
|
186
|
-
csv(
|
|
207
|
+
csv(options?: ModelExportOptions, config?: Papa.UnparseConfig): string;
|
|
187
208
|
clone(): any;
|
|
188
209
|
/**
|
|
189
210
|
* Retrieves the schema of the current model based on the selected format
|
|
190
|
-
* @param
|
|
211
|
+
* @param includeTitleAndDraft boolean whether the title and JSON schema draft version should be referenced in the schema
|
|
191
212
|
* @returns the schema for the current model
|
|
192
213
|
*/
|
|
193
|
-
static schema(
|
|
214
|
+
static schema(includeTitleAndDraft?: boolean): {
|
|
194
215
|
[string: string]: any;
|
|
195
216
|
};
|
|
196
217
|
toString(): string;
|
|
@@ -201,9 +222,9 @@ export declare class Model {
|
|
|
201
222
|
*/
|
|
202
223
|
private static buildPropTree;
|
|
203
224
|
/**
|
|
204
|
-
* Constructs a model from
|
|
205
|
-
* @param data JSON object
|
|
206
|
-
* @param
|
|
225
|
+
* Constructs a model from JSON objects
|
|
226
|
+
* @param data JSON object or array of JSON object
|
|
227
|
+
* @param options
|
|
207
228
|
* @private
|
|
208
229
|
*/
|
|
209
230
|
private static fromObject;
|