yayson 4.0.0 → 4.1.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.
- package/README.md +229 -82
- package/build/legacy.cjs +84 -31
- package/build/legacy.d.cts +12 -4
- package/build/legacy.d.cts.map +1 -1
- package/build/legacy.d.mts +12 -4
- package/build/legacy.d.mts.map +1 -1
- package/build/legacy.mjs +84 -31
- package/build/legacy.mjs.map +1 -1
- package/build/{types-BsfPiPEw.d.mts → types-Do2flKZX.d.mts} +9 -2
- package/build/{types-BsfPiPEw.d.mts.map → types-Do2flKZX.d.mts.map} +1 -1
- package/build/{types-DbMIe8E2.d.cts → types-NiKV-lj-.d.cts} +9 -2
- package/build/{types-DbMIe8E2.d.cts.map → types-NiKV-lj-.d.cts.map} +1 -1
- package/build/utils.d.cts +1 -1
- package/build/utils.d.mts +1 -1
- package/build/{yayson-BKEyEcGk.d.cts → yayson-3UYKq2H5.d.cts} +14 -2
- package/build/yayson-3UYKq2H5.d.cts.map +1 -0
- package/build/{yayson-CRbukIqr.d.mts → yayson-Ce5uGpgU.d.mts} +14 -2
- package/build/yayson-Ce5uGpgU.d.mts.map +1 -0
- package/build/{yayson-BJv2Z0Z6.mjs → yayson-CwZg5FNt.mjs} +95 -34
- package/build/yayson-CwZg5FNt.mjs.map +1 -0
- package/build/{yayson-CUfrxK9d.cjs → yayson-l2JKseMH.cjs} +94 -33
- package/build/yayson.cjs +1 -1
- package/build/yayson.d.cts +2 -2
- package/build/yayson.d.mts +2 -2
- package/build/yayson.mjs +1 -1
- package/package.json +1 -1
- package/build/yayson-BJv2Z0Z6.mjs.map +0 -1
- package/build/yayson-BKEyEcGk.d.cts.map +0 -1
- package/build/yayson-CRbukIqr.d.mts.map +0 -1
package/build/legacy.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as Presenter, r as yayson$1, t as YaysonOptions } from "./yayson-
|
|
1
|
+
import { E as ModelLike, T as Adapter, _ as StoreResult, a as JsonApiRelationship, c as LegacyPresenterOptions, d as SchemaRegistry, f as StoreModel, i as JsonApiLinks, l as LegacyStoreOptions, m as StoreModels, n as JsonApiDocument, o as JsonApiRelationships, p as StoreModelWithOptionalId, r as JsonApiLink, s as JsonApiResource, t as InferModelType, u as PresenterOptions, v as ValidationError } from "./types-Do2flKZX.mjs";
|
|
2
|
+
import { i as Presenter, r as yayson$1, t as YaysonOptions } from "./yayson-Ce5uGpgU.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/yayson/legacy-presenter.d.ts
|
|
5
5
|
interface LegacyJsonApiDocument extends JsonApiDocument {
|
|
@@ -13,6 +13,7 @@ declare function createLegacyPresenter(Presenter: Presenter): {
|
|
|
13
13
|
attributes(instance: ModelLike | null): Record<string, unknown>;
|
|
14
14
|
includeRelationships(scope: LegacyJsonApiDocument, instance: ModelLike): unknown[];
|
|
15
15
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null | undefined, options?: LegacyPresenterOptions): LegacyJsonApiDocument;
|
|
16
|
+
payload(instance: ModelLike): LegacyJsonApiDocument;
|
|
16
17
|
render(instanceOrCollection: ModelLike | ModelLike[] | null): LegacyJsonApiDocument;
|
|
17
18
|
id(instance: ModelLike): string | undefined;
|
|
18
19
|
selfLinks(_instance: ModelLike): JsonApiLink | string | undefined;
|
|
@@ -30,6 +31,7 @@ declare function createLegacyPresenter(Presenter: Presenter): {
|
|
|
30
31
|
buildRelationships(instance: ModelLike | null): JsonApiRelationships | null;
|
|
31
32
|
buildSelfLink(instance: ModelLike): JsonApiLink | undefined;
|
|
32
33
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null | undefined, options?: PresenterOptions): JsonApiDocument;
|
|
34
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
33
35
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
34
36
|
};
|
|
35
37
|
adapter: typeof Adapter;
|
|
@@ -37,6 +39,7 @@ declare function createLegacyPresenter(Presenter: Presenter): {
|
|
|
37
39
|
fields?: string[];
|
|
38
40
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
39
41
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
42
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
40
43
|
}>;
|
|
41
44
|
buildRelationships(instance: ModelLike | null): JsonApiRelationships | null;
|
|
42
45
|
buildSelfLink(instance: ModelLike): JsonApiLink | undefined;
|
|
@@ -44,8 +47,9 @@ declare function createLegacyPresenter(Presenter: Presenter): {
|
|
|
44
47
|
type: string;
|
|
45
48
|
plural?: string;
|
|
46
49
|
fields?: string[];
|
|
47
|
-
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null, options?: LegacyPresenterOptions):
|
|
48
|
-
render(instanceOrCollection: ModelLike | ModelLike[] | null, _options?: LegacyPresenterOptions):
|
|
50
|
+
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null, options?: LegacyPresenterOptions): LegacyJsonApiDocument;
|
|
51
|
+
render(instanceOrCollection: ModelLike | ModelLike[] | null, _options?: LegacyPresenterOptions): LegacyJsonApiDocument;
|
|
52
|
+
payload(instance: ModelLike): LegacyJsonApiDocument;
|
|
49
53
|
adapter: typeof Adapter;
|
|
50
54
|
};
|
|
51
55
|
//#endregion
|
|
@@ -53,6 +57,7 @@ declare function createLegacyPresenter(Presenter: Presenter): {
|
|
|
53
57
|
interface LegacyStoreRecordType {
|
|
54
58
|
type: string;
|
|
55
59
|
data: Record<string, unknown> & {
|
|
60
|
+
id?: string | number;
|
|
56
61
|
meta?: Record<string, unknown>;
|
|
57
62
|
links?: Record<string, unknown>;
|
|
58
63
|
};
|
|
@@ -69,6 +74,7 @@ interface LegacyData {
|
|
|
69
74
|
[key: string]: LegacyDataValue | LegacyLinks | Record<string, unknown> | undefined;
|
|
70
75
|
}
|
|
71
76
|
declare class LegacyStore<S extends SchemaRegistry = SchemaRegistry> {
|
|
77
|
+
#private;
|
|
72
78
|
types: Record<string, string>;
|
|
73
79
|
records: LegacyStoreRecordType[];
|
|
74
80
|
relations: Record<string, Record<string, string>>;
|
|
@@ -82,6 +88,8 @@ declare class LegacyStore<S extends SchemaRegistry = SchemaRegistry> {
|
|
|
82
88
|
setupRelations(links: LegacyLinks): void;
|
|
83
89
|
findRecord(type: string, id: string): LegacyStoreRecordType | undefined;
|
|
84
90
|
findRecords(type: string): LegacyStoreRecordType[];
|
|
91
|
+
static build(data: LegacyData): StoreModelWithOptionalId;
|
|
92
|
+
build(data: LegacyData): StoreModelWithOptionalId;
|
|
85
93
|
/** @deprecated Use retrieve() instead. */
|
|
86
94
|
retrive<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null;
|
|
87
95
|
retrieve<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null;
|
package/build/legacy.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.mts","names":[],"sources":["../../../../../../yayson/legacy-presenter.ts","../../../../../../yayson/legacy-store.ts","../../../../../../legacy.ts"],"mappings":";;;;UASU,qBAAA,SAA8B,eAAA;EAAA,CACrC,GAAA;AAAA;AAAA,iBAIqB,qBAAA,CAAsB,SAAA,EAAW,SAAA;EAAA,aASjC,eAAA;iBAbV;WAOK,qBAAA;;
|
|
1
|
+
{"version":3,"file":"legacy.d.mts","names":[],"sources":["../../../../../../yayson/legacy-presenter.ts","../../../../../../yayson/legacy-store.ts","../../../../../../legacy.ts"],"mappings":";;;;UASU,qBAAA,SAA8B,eAAA;EAAA,CACrC,GAAA;AAAA;AAAA,iBAIqB,qBAAA,CAAsB,SAAA,EAAW,SAAA;EAAA,aASjC,eAAA;iBAbV;WAOK,qBAAA;;yBAqBM,SAAA,UAAmB,MAAA;gCA8BZ,qBAAA,EAAqB,QAAA,EAAY,SAAA;iCAqCrC,SAA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CAAM,IAAA,EAAM,UAAA,GAAa,wBAAA;EAIhC,KAAA,CAAM,IAAA,EAAM,UAAA,GAAa,wBAAA;;EA2BzB,OAAA,kBAAA,CAA0B,IAAA,EAAM,CAAA,EAAG,IAAA,EAAM,UAAA,GAAa,cAAA,CAAe,CAAA,EAAG,CAAA;EAIxE,QAAA,kBAAA,CAA2B,IAAA,EAAM,CAAA,EAAG,IAAA,EAAM,UAAA,GAAa,cAAA,CAAe,CAAA,EAAG,CAAA;EAYzE,IAAA,kBAAA,CAAuB,IAAA,EAAM,CAAA,EAAG,EAAA,mBAAqB,MAAA,GAAS,WAAA,GAAc,cAAA,CAAe,CAAA,EAAG,CAAA;EAM9F,OAAA,kBAAA,CAA0B,IAAA,EAAM,CAAA,EAAG,MAAA,GAAS,WAAA,GAAc,cAAA,CAAe,CAAA,EAAG,CAAA;EAgB5E,MAAA,CAAO,IAAA,UAAc,EAAA;EAsBrB,OAAA,CAAQ,IAAA,EAAM,UAAA,GAAa,WAAA;EA4C3B,IAAA,CAAK,IAAA,EAAM,UAAA,GAAa,UAAA,GAAa,WAAA;EAYrC,WAAA,kBAAA,CAA8B,IAAA,EAAM,CAAA,EAAG,IAAA,EAAM,UAAA,GAAa,WAAA,CAAY,cAAA,CAAe,CAAA,EAAG,CAAA;AAAA;;;UCjUhF,kBAAA;EACR,KAAA,SAAc,WAAA;EACd,SAAA,EAAW,UAAA,QAAkB,qBAAA;EAC7B,OAAA,EAAS,UAAA,QAAkB,QAAA;AAAA;AAAA,iBAGL,MAAA,CAAO,OAAA,GAAU,aAAA,GAAgB,kBAAA"}
|
package/build/legacy.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as TYPE, n as META, t as LINKS } from "./symbols-DSjKJ8vh.mjs";
|
|
2
|
-
import { n as validate, r as filterByFields, t as yayson_default } from "./yayson-
|
|
2
|
+
import { n as validate, r as filterByFields, t as yayson_default } from "./yayson-CwZg5FNt.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/yayson/legacy-presenter.ts
|
|
5
|
-
function hasId(value) {
|
|
5
|
+
function hasId$1(value) {
|
|
6
6
|
return typeof value === "object" && value !== null && "id" in value;
|
|
7
7
|
}
|
|
8
8
|
function createLegacyPresenter(Presenter) {
|
|
@@ -27,8 +27,8 @@ function createLegacyPresenter(Presenter) {
|
|
|
27
27
|
if (data == null) {
|
|
28
28
|
id = attributes[key + "Id"];
|
|
29
29
|
if (id != null) attributes[key] = id;
|
|
30
|
-
} else if (Array.isArray(data)) attributes[key] = data.map((obj) => hasId(obj) ? obj.id : obj);
|
|
31
|
-
else if (hasId(data)) attributes[key] = data.id;
|
|
30
|
+
} else if (Array.isArray(data)) attributes[key] = data.map((obj) => hasId$1(obj) ? obj.id : obj);
|
|
31
|
+
else if (hasId$1(data)) attributes[key] = data.id;
|
|
32
32
|
}
|
|
33
33
|
const relationshipKeys = relationships ? Object.keys(relationships) : [];
|
|
34
34
|
return filterByFields(attributes, this.constructor.fields ? [...this.constructor.fields, ...relationshipKeys] : void 0);
|
|
@@ -72,7 +72,7 @@ function createLegacyPresenter(Presenter) {
|
|
|
72
72
|
}
|
|
73
73
|
if (this.scope[this.constructor.type] && !this.scope[this.pluralType()]) {
|
|
74
74
|
const existingValue = this.scope[this.constructor.type];
|
|
75
|
-
if (attrs && hasId(existingValue) && existingValue.id !== attrs.id) {
|
|
75
|
+
if (attrs && hasId$1(existingValue) && existingValue.id !== attrs.id) {
|
|
76
76
|
this.scope[this.pluralType()] = [this.scope[this.constructor.type]];
|
|
77
77
|
delete this.scope[this.constructor.type];
|
|
78
78
|
const pluralArray = this.scope[this.pluralType()];
|
|
@@ -80,7 +80,7 @@ function createLegacyPresenter(Presenter) {
|
|
|
80
80
|
} else added = false;
|
|
81
81
|
} else if (this.scope[this.pluralType()]) {
|
|
82
82
|
const existing = this.scope[this.pluralType()];
|
|
83
|
-
if (Array.isArray(existing)) if (attrs && !existing.some((i) => hasId(i) && i.id === attrs.id)) existing.push(attrs);
|
|
83
|
+
if (Array.isArray(existing)) if (attrs && !existing.some((i) => hasId$1(i) && i.id === attrs.id)) existing.push(attrs);
|
|
84
84
|
else added = false;
|
|
85
85
|
} else if (opts.defaultPlural) this.scope[this.pluralType()] = attrs ? [attrs] : [];
|
|
86
86
|
else this.scope[this.constructor.type] = attrs;
|
|
@@ -88,6 +88,11 @@ function createLegacyPresenter(Presenter) {
|
|
|
88
88
|
}
|
|
89
89
|
return this.scope;
|
|
90
90
|
}
|
|
91
|
+
payload(instance) {
|
|
92
|
+
if (Array.isArray(instance)) throw new Error("payload() expects a single resource, not an array");
|
|
93
|
+
if (instance == null) throw new Error("payload() requires a resource, got null");
|
|
94
|
+
return { [this.constructor.type]: this.attributes(instance) };
|
|
95
|
+
}
|
|
91
96
|
render(instanceOrCollection) {
|
|
92
97
|
return this.toJSON(instanceOrCollection);
|
|
93
98
|
}
|
|
@@ -97,12 +102,18 @@ function createLegacyPresenter(Presenter) {
|
|
|
97
102
|
static render(instanceOrCollection, _options) {
|
|
98
103
|
return new this().render(instanceOrCollection);
|
|
99
104
|
}
|
|
105
|
+
static payload(instance) {
|
|
106
|
+
return new this().payload(instance);
|
|
107
|
+
}
|
|
100
108
|
};
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
//#endregion
|
|
104
112
|
//#region src/yayson/legacy-store.ts
|
|
105
|
-
|
|
113
|
+
function hasId(model) {
|
|
114
|
+
return model.id != null;
|
|
115
|
+
}
|
|
116
|
+
var LegacyStore = class LegacyStore {
|
|
106
117
|
types;
|
|
107
118
|
records;
|
|
108
119
|
relations;
|
|
@@ -125,33 +136,56 @@ var LegacyStore = class {
|
|
|
125
136
|
this.validationErrors = [];
|
|
126
137
|
this.models = {};
|
|
127
138
|
}
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
id: rec.data.id
|
|
135
|
-
};
|
|
136
|
-
model[TYPE] = type;
|
|
137
|
-
if (rec.data.meta != null) model[META] = rec.data.meta;
|
|
138
|
-
if (rec.data.links != null) model[LINKS] = rec.data.links;
|
|
139
|
-
models[type][idStr] = model;
|
|
139
|
+
#createStub(type, id) {
|
|
140
|
+
const stub = { id };
|
|
141
|
+
stub[TYPE] = type;
|
|
142
|
+
return stub;
|
|
143
|
+
}
|
|
144
|
+
#resolveRelationships(model, type, resolver) {
|
|
140
145
|
const relations = this.relations[type];
|
|
141
|
-
if (relations)
|
|
146
|
+
if (!relations) return;
|
|
147
|
+
for (const attribute in relations) {
|
|
142
148
|
const relationType = relations[attribute];
|
|
143
149
|
const value = model[attribute];
|
|
144
|
-
|
|
150
|
+
if (Array.isArray(value)) model[attribute] = value.filter((id) => id != null).map((id) => resolver(relationType, String(id)));
|
|
151
|
+
else if (value != null) model[attribute] = resolver(relationType, String(value));
|
|
152
|
+
else model[attribute] = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
#createModel(rec, type, options) {
|
|
156
|
+
const models = options?.models;
|
|
157
|
+
const model = { ...rec.data };
|
|
158
|
+
if (rec.data.id != null) model.id = rec.data.id;
|
|
159
|
+
model[TYPE] = type;
|
|
160
|
+
if (rec.data.meta != null) model[META] = rec.data.meta;
|
|
161
|
+
if (rec.data.links != null) model[LINKS] = rec.data.links;
|
|
162
|
+
if (models && hasId(model)) {
|
|
163
|
+
const idStr = String(model.id);
|
|
164
|
+
if (!models[type]) models[type] = {};
|
|
165
|
+
models[type][idStr] = model;
|
|
145
166
|
}
|
|
167
|
+
const resolver = (relationType, id) => {
|
|
168
|
+
return this.#findModel(relationType, id, models ?? {}) ?? this.#createStub(relationType, id);
|
|
169
|
+
};
|
|
170
|
+
this.#resolveRelationships(model, type, resolver);
|
|
171
|
+
return model;
|
|
172
|
+
}
|
|
173
|
+
toModel(rec, type, models) {
|
|
174
|
+
const idStr = String(rec.data.id);
|
|
175
|
+
if (!models[type]) models[type] = {};
|
|
176
|
+
if (models[type][idStr]) return models[type][idStr];
|
|
177
|
+
const result = this.#createModel(rec, type, { models });
|
|
178
|
+
if (!hasId(result)) throw new Error(`Expected model of type ${type} to have an id`);
|
|
179
|
+
const model = result;
|
|
146
180
|
if (this.schemas && this.schemas[type]) {
|
|
147
181
|
const schema = this.schemas[type];
|
|
148
|
-
const result = validate(schema, model, this.strict);
|
|
149
|
-
if (!result.valid) this.validationErrors.push({
|
|
182
|
+
const result$1 = validate(schema, model, this.strict);
|
|
183
|
+
if (!result$1.valid) this.validationErrors.push({
|
|
150
184
|
type,
|
|
151
185
|
id: idStr,
|
|
152
|
-
error: result.error
|
|
186
|
+
error: result$1.error
|
|
153
187
|
});
|
|
154
|
-
const validatedModel = result.data;
|
|
188
|
+
const validatedModel = result$1.data;
|
|
155
189
|
validatedModel[TYPE] = model[TYPE];
|
|
156
190
|
validatedModel[LINKS] = model[LINKS];
|
|
157
191
|
validatedModel[META] = model[META];
|
|
@@ -177,6 +211,30 @@ var LegacyStore = class {
|
|
|
177
211
|
findRecords(type) {
|
|
178
212
|
return this.records.filter((r) => r.type === type);
|
|
179
213
|
}
|
|
214
|
+
#findModel(type, id, models) {
|
|
215
|
+
const rec = this.findRecord(type, id);
|
|
216
|
+
if (rec == null) return null;
|
|
217
|
+
return models[type]?.[id] ?? this.toModel(rec, type, models);
|
|
218
|
+
}
|
|
219
|
+
static build(data) {
|
|
220
|
+
return new LegacyStore().build(data);
|
|
221
|
+
}
|
|
222
|
+
build(data) {
|
|
223
|
+
if (data.links) this.setupRelations(data.links);
|
|
224
|
+
let name;
|
|
225
|
+
for (const key in data) if (key !== "meta" && key !== "links") {
|
|
226
|
+
name = key;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (name == null) throw new Error("build() expects a single resource, not an array");
|
|
230
|
+
const value = data[name];
|
|
231
|
+
if (value == null || Array.isArray(value)) throw new Error("build() expects a single resource, not an array");
|
|
232
|
+
const type = this.types[name] || name;
|
|
233
|
+
return this.#createModel({
|
|
234
|
+
type,
|
|
235
|
+
data: value
|
|
236
|
+
}, type);
|
|
237
|
+
}
|
|
180
238
|
/** @deprecated Use retrieve() instead. */
|
|
181
239
|
retrive(type, data) {
|
|
182
240
|
return this.retrieve(type, data);
|
|
@@ -190,12 +248,7 @@ var LegacyStore = class {
|
|
|
190
248
|
return model;
|
|
191
249
|
}
|
|
192
250
|
find(type, id, models) {
|
|
193
|
-
|
|
194
|
-
const idStr = String(id);
|
|
195
|
-
const rec = this.findRecord(type, idStr);
|
|
196
|
-
if (rec == null) return null;
|
|
197
|
-
if (!modelsObj[type]) modelsObj[type] = {};
|
|
198
|
-
return modelsObj[type][idStr] || this.toModel(rec, type, modelsObj);
|
|
251
|
+
return this.#findModel(type, String(id), models ?? this.models);
|
|
199
252
|
}
|
|
200
253
|
findAll(type, models) {
|
|
201
254
|
const modelsObj = models ?? this.models;
|
package/build/legacy.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.mjs","names":["yaysonFactory"],"sources":["../src/yayson/legacy-presenter.ts","../src/yayson/legacy-store.ts","../src/legacy.ts"],"sourcesContent":["import type { ModelLike } from './adapter.js'\nimport type { Presenter } from './presenter.js'\nimport type { JsonApiDocument, JsonApiLinks, LegacyPresenterOptions } from './types.js'\nimport { filterByFields } from './utils.js'\n\nfunction hasId(value: unknown): value is { id: unknown } {\n return typeof value === 'object' && value !== null && 'id' in value\n}\n\ninterface LegacyJsonApiDocument extends JsonApiDocument {\n [key: string]: unknown\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is inferred from class\nexport default function createLegacyPresenter(Presenter: Presenter) {\n return class LegacyPresenter extends Presenter {\n declare ['constructor']: typeof LegacyPresenter\n declare scope: LegacyJsonApiDocument\n\n static type = 'object'\n static plural?: string\n static fields?: string[]\n\n constructor(scope?: JsonApiDocument) {\n // LegacyPresenter doesn't use the 'data' property, so pass an empty scope\n const emptyScope: JsonApiDocument = { data: null }\n super(scope || emptyScope)\n // Remove the 'data' property that the parent constructor adds\n if (!scope) {\n // Legacy format doesn't include 'data' property\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Need Partial to allow delete\n delete (this.scope as Partial<JsonApiDocument>).data\n }\n }\n\n pluralType(): string {\n return this.constructor.plural || this.constructor.type + 's'\n }\n\n attributes(instance: ModelLike | null): Record<string, unknown> {\n if (!instance) {\n return {}\n }\n const attributes = { ...this.constructor.adapter.get(instance) }\n const relationships = this.relationships()\n if (relationships) {\n for (const key in relationships) {\n let id: unknown\n const data = attributes[key]\n if (data == null) {\n id = attributes[key + 'Id']\n if (id != null) {\n attributes[key] = id\n }\n } else if (Array.isArray(data)) {\n attributes[key] = data.map((obj: unknown) => (hasId(obj) ? obj.id : obj))\n } else if (hasId(data)) {\n attributes[key] = data.id\n }\n }\n }\n\n // Include relationship keys in allowed fields (so users don't need to list them twice)\n const relationshipKeys = relationships ? Object.keys(relationships) : []\n const allowedFields = this.constructor.fields ? [...this.constructor.fields, ...relationshipKeys] : undefined\n\n return filterByFields(attributes, allowedFields)\n }\n\n includeRelationships(scope: LegacyJsonApiDocument, instance: ModelLike): unknown[] {\n if (!scope.links) {\n scope.links = {}\n }\n const relationships = this.relationships()\n const result: unknown[] = []\n\n if (!relationships) {\n return result\n }\n\n for (const key in relationships) {\n const factory = relationships[key]\n if (!factory) throw new Error(`Presenter for ${key} in ${this.constructor.type} is not defined`)\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Factory returns PresenterInstance, we know it's LegacyPresenter\n const presenter = new factory(scope) as LegacyPresenter\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- unknown from adapter.get\n const data = this.constructor.adapter.get(instance, key) as ModelLike | ModelLike[] | null\n if (data != null) {\n presenter.toJSON(data, { defaultPlural: true })\n }\n\n const type = scope[this.pluralType()] != null ? this.pluralType() : this.constructor.type\n const presenterType = presenter.constructor.type\n const keyName = scope[presenter.pluralType()] != null ? presenter.pluralType() : presenterType\n const link = { type: keyName }\n if (scope.links) {\n scope.links[`${type}.${key}`] = link\n }\n result.push(link)\n }\n return result\n }\n\n toJSON(\n instanceOrCollection: ModelLike | ModelLike[] | null | undefined,\n options?: LegacyPresenterOptions,\n ): LegacyJsonApiDocument {\n const opts = options ?? {}\n if (!this.scope.links) {\n this.scope.links = {}\n }\n if (Array.isArray(instanceOrCollection)) {\n const collection = instanceOrCollection\n const type = this.pluralType()\n if (!this.scope[type]) {\n this.scope[type] = []\n }\n collection.forEach((instance: ModelLike) => {\n return this.toJSON(instance)\n })\n } else {\n let links: JsonApiLinks | undefined\n const instance = instanceOrCollection\n let added = true\n const attrs = instance ? this.attributes(instance) : null\n if ((links = this.links())) {\n if (attrs) {\n attrs.links = links\n }\n }\n // If eg x.image already exists\n if (this.scope[this.constructor.type] && !this.scope[this.pluralType()]) {\n const existingValue = this.scope[this.constructor.type]\n if (attrs && hasId(existingValue) && existingValue.id !== attrs.id) {\n this.scope[this.pluralType()] = [this.scope[this.constructor.type]]\n delete this.scope[this.constructor.type]\n const pluralArray = this.scope[this.pluralType()]\n if (Array.isArray(pluralArray)) {\n pluralArray.push(attrs)\n }\n } else {\n added = false\n }\n\n // If eg x.images already exists\n } else if (this.scope[this.pluralType()]) {\n const existing = this.scope[this.pluralType()]\n if (Array.isArray(existing)) {\n if (attrs && !existing.some((i) => hasId(i) && i.id === attrs.id)) {\n existing.push(attrs)\n } else {\n added = false\n }\n }\n } else if (opts.defaultPlural) {\n this.scope[this.pluralType()] = attrs ? [attrs] : []\n } else {\n this.scope[this.constructor.type] = attrs\n }\n\n if (added && instance) {\n this.includeRelationships(this.scope, instance)\n }\n }\n return this.scope\n }\n\n render(instanceOrCollection: ModelLike | ModelLike[] | null): LegacyJsonApiDocument {\n return this.toJSON(instanceOrCollection)\n }\n\n static toJSON(\n instanceOrCollection: ModelLike | ModelLike[] | null,\n options?: LegacyPresenterOptions,\n ): JsonApiDocument {\n return new this().toJSON(instanceOrCollection, options)\n }\n\n static render(\n instanceOrCollection: ModelLike | ModelLike[] | null,\n _options?: LegacyPresenterOptions,\n ): JsonApiDocument {\n return new this().render(instanceOrCollection)\n }\n }\n}\n","import type {\n StoreModel,\n StoreModels,\n StoreResult,\n SchemaRegistry,\n ValidationError,\n InferModelType,\n LegacyStoreOptions,\n} from './types.js'\nimport { TYPE, LINKS, META } from './symbols.js'\nimport { validate } from './schema.js'\n\ninterface LegacyStoreRecordType {\n type: string\n data: Record<string, unknown> & {\n meta?: Record<string, unknown>\n links?: Record<string, unknown>\n }\n}\n\ninterface LegacyLinks {\n [key: string]: {\n type: string\n }\n}\n\ntype LegacyDataValue = Record<string, unknown> | Array<Record<string, unknown>>\n\nexport interface LegacyData {\n links?: LegacyLinks\n meta?: Record<string, unknown>\n [key: string]: LegacyDataValue | LegacyLinks | Record<string, unknown> | undefined\n}\n\nexport default class LegacyStore<S extends SchemaRegistry = SchemaRegistry> {\n types: Record<string, string>\n records: LegacyStoreRecordType[]\n relations: Record<string, Record<string, string>>\n schemas?: S\n strict: boolean\n validationErrors: ValidationError[]\n models: StoreModels\n\n constructor(options?: LegacyStoreOptions<S>) {\n this.types = options?.types || {}\n this.schemas = options?.schemas\n this.strict = options?.strict ?? false\n this.records = []\n this.relations = {}\n this.validationErrors = []\n this.models = {}\n }\n\n reset(): void {\n this.records = []\n this.relations = {}\n this.validationErrors = []\n this.models = {}\n }\n\n toModel(rec: LegacyStoreRecordType, type: string, models: StoreModels): StoreModel {\n // Keep original id type from data, but ensure string key for models lookup\n const idStr = String(rec.data.id)\n\n if (!models[type]) {\n models[type] = {}\n }\n\n // Return cached model if already built (prevents double validation)\n if (models[type]![idStr]) {\n return models[type]![idStr]!\n }\n\n // Don't add 'type' to model - preserve original data shape for backwards compatibility\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Legacy format: rec.data has id, spread creates StoreModel-compatible object\n const model: StoreModel = { ...rec.data, id: rec.data.id as string }\n model[TYPE] = type\n if (rec.data.meta != null) {\n model[META] = rec.data.meta\n }\n if (rec.data.links != null) {\n model[LINKS] = rec.data.links\n }\n\n // Store placeholder to handle circular relations\n models[type]![idStr] = model\n\n const relations = this.relations[type]\n if (relations) {\n for (const attribute in relations) {\n const relationType = relations[attribute]!\n const value = model[attribute]\n model[attribute] = Array.isArray(value)\n ? value.map((id: unknown) => this.find(relationType, String(id), models))\n : this.find(relationType, String(value), models)\n }\n }\n\n // Validate with schema if provided\n if (this.schemas && this.schemas[type]) {\n const schema = this.schemas[type]\n const result = validate(schema, model, this.strict)\n\n if (!result.valid) {\n this.validationErrors.push({\n type,\n id: idStr,\n error: result.error,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Schema validation returns unknown, cast to StoreModel after validation\n const validatedModel = result.data as StoreModel\n\n // Preserve symbol keys from original model (schema validation may not preserve them)\n validatedModel[TYPE] = model[TYPE]\n validatedModel[LINKS] = model[LINKS]\n validatedModel[META] = model[META]\n\n models[type]![idStr] = validatedModel\n return validatedModel\n }\n\n return model\n }\n\n setupRelations(links: LegacyLinks): void {\n for (const key in links) {\n const value = links[key]!\n const parts = key.split('.')\n const typeRaw = parts[0]!\n const attribute = parts[1]!\n const type = this.types[typeRaw] || typeRaw\n if (!this.relations[type]) {\n this.relations[type] = {}\n }\n this.relations[type]![attribute] = this.types[value.type] || value.type\n }\n }\n\n findRecord(type: string, id: string): LegacyStoreRecordType | undefined {\n return this.records.find((r) => r.type === type && String(r.data.id) === id)\n }\n\n findRecords(type: string): LegacyStoreRecordType[] {\n return this.records.filter((r) => r.type === type)\n }\n\n /** @deprecated Use retrieve() instead. */\n retrive<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null {\n return this.retrieve(type, data)\n }\n\n retrieve<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null {\n const synced = this.syncAll(data)\n const normalizedType = this.types[type] || type\n const model = synced.find((m) => m[TYPE] === normalizedType)\n if (!model) return null\n if (synced[META]) {\n model[META] = synced[META]\n }\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Enable type inference from type parameter\n return model as InferModelType<S, T>\n }\n\n find<T extends string>(type: T, id: string | number, models?: StoreModels): InferModelType<S, T> | null {\n const modelsObj = models ?? this.models\n const idStr = String(id)\n const rec = this.findRecord(type, idStr)\n if (rec == null) {\n return null\n }\n if (!modelsObj[type]) {\n modelsObj[type] = {}\n }\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type inference: maps string literal type parameter to schema type\n return (modelsObj[type]![idStr] || this.toModel(rec, type, modelsObj)) as InferModelType<S, T>\n }\n\n findAll<T extends string>(type: T, models?: StoreModels): InferModelType<S, T>[] {\n const modelsObj = models ?? this.models\n const recs = this.findRecords(type)\n if (recs.length === 0) {\n return []\n }\n recs.forEach((rec) => {\n if (!modelsObj[type]) {\n modelsObj[type] = {}\n }\n return this.toModel(rec, type, modelsObj)\n })\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type inference: maps string literal type parameter to schema type\n return Object.values(modelsObj[type] || {}) as InferModelType<S, T>[]\n }\n\n remove(type: string, id?: string | number): void {\n const normalizedType = this.types[type] || type\n\n const removeOne = (record: LegacyStoreRecordType): void => {\n const index = this.records.indexOf(record)\n if (!(index < 0)) {\n this.records.splice(index, 1)\n }\n }\n\n if (id != null) {\n const idStr = String(id)\n const record = this.findRecord(normalizedType, idStr)\n if (record) {\n removeOne(record)\n }\n } else {\n const records = this.findRecords(normalizedType)\n records.forEach(removeOne)\n }\n }\n\n syncAll(data: LegacyData): StoreResult {\n // Clear validation errors and models cache from previous sync\n this.validationErrors = []\n this.models = {}\n\n if (data.links) {\n this.setupRelations(data.links)\n }\n\n // Track records added in this sync\n const syncedRecords: LegacyStoreRecordType[] = []\n\n for (const name in data) {\n if (name === 'meta' || name === 'links') {\n continue\n }\n\n const value = data[name]!\n const type = this.types[name] || name\n\n const add = (d: Record<string, unknown>): void => {\n this.remove(type, String(d.id))\n const rec: LegacyStoreRecordType = { type, data: d }\n this.records.push(rec)\n syncedRecords.push(rec)\n }\n\n if (Array.isArray(value)) {\n value.forEach(add)\n } else if (typeof value === 'object' && value !== null) {\n add(value)\n }\n }\n\n // Build models for all synced records\n for (const rec of syncedRecords) {\n this.toModel(rec, rec.type, this.models)\n }\n\n const result: StoreResult = syncedRecords.map((rec) => this.models[rec.type]![String(rec.data.id)]!)\n if (data.meta != null) {\n result[META] = data.meta\n }\n return result\n }\n\n sync(data: LegacyData): StoreModel | StoreResult {\n const result = this.syncAll(data)\n if (result.length === 1) {\n const model = result[0]\n if (result[META]) {\n model[META] = result[META]\n }\n return model\n }\n return result\n }\n\n retrieveAll<T extends string>(type: T, data: LegacyData): StoreResult<InferModelType<S, T>> {\n const normalizedType = this.types[type] || type\n const synced = this.syncAll(data)\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Enable type inference from type parameter\n const result: StoreResult<InferModelType<S, T>> = synced.filter(\n (model) => model[TYPE] === normalizedType,\n ) as StoreResult<InferModelType<S, T>>\n result[META] = synced[META]\n return result\n }\n}\n","import yaysonFactory from './yayson.js'\nimport createLegacyPresenter from './yayson/legacy-presenter.js'\nimport LegacyStore from './yayson/legacy-store.js'\nimport type { LegacyData } from './yayson/legacy-store.js'\nimport Adapter from './yayson/adapter.js'\nimport type {\n JsonApiDocument,\n JsonApiLink,\n JsonApiLinks,\n JsonApiRelationship,\n JsonApiRelationships,\n JsonApiResource,\n} from './yayson/types.js'\nimport type { YaysonOptions } from './yayson.js'\n\nexport type {\n Adapter,\n JsonApiDocument,\n JsonApiLink,\n JsonApiLinks,\n JsonApiRelationship,\n JsonApiRelationships,\n JsonApiResource,\n LegacyData,\n}\n\ninterface LegacyYaysonResult {\n Store: typeof LegacyStore\n Presenter: ReturnType<typeof createLegacyPresenter>\n Adapter: ReturnType<typeof yaysonFactory>['Adapter']\n}\n\nexport default function yayson(options?: YaysonOptions): LegacyYaysonResult {\n const { Presenter, Adapter } = yaysonFactory(options)\n return {\n Store: LegacyStore,\n Presenter: createLegacyPresenter(Presenter),\n Adapter,\n }\n}\n"],"mappings":";;;;AAKA,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AAM,SAAS,KAAK,QAAQ,KAAK;AACjC,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,QAAQ,OAAO;AACrB,OAAI,OAAO,MACT,OAAM,QAAQ,OAAO;AAEvB,UAAO;;AAET,SAAO;;CAGT,YAA8B,MAAS,MAAqD;EAC1F,MAAM,iBAAiB,KAAK,MAAM,SAAS;EAC3C,MAAM,SAAS,KAAK,QAAQ,KAAK;EAEjC,MAAM,SAA4C,OAAO,QACtD,UAAU,MAAM,UAAU,eAC5B;AACD,SAAO,QAAQ,OAAO;AACtB,SAAO;;;;;;AC3PX,SAAwB,OAAO,SAA6C;CAC1E,MAAM,EAAE,WAAW,YAAYA,eAAc,QAAQ;AACrD,QAAO;EACL,OAAO;EACP,WAAW,sBAAsB,UAAU;EAC3C;EACD"}
|
|
1
|
+
{"version":3,"file":"legacy.mjs","names":["hasId","#findModel","#createStub","#resolveRelationships","#createModel","result","yaysonFactory"],"sources":["../src/yayson/legacy-presenter.ts","../src/yayson/legacy-store.ts","../src/legacy.ts"],"sourcesContent":["import type { ModelLike } from './adapter.js'\nimport type { Presenter } from './presenter.js'\nimport type { JsonApiDocument, JsonApiLinks, LegacyPresenterOptions } from './types.js'\nimport { filterByFields } from './utils.js'\n\nfunction hasId(value: unknown): value is { id: unknown } {\n return typeof value === 'object' && value !== null && 'id' in value\n}\n\ninterface LegacyJsonApiDocument extends JsonApiDocument {\n [key: string]: unknown\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is inferred from class\nexport default function createLegacyPresenter(Presenter: Presenter) {\n return class LegacyPresenter extends Presenter {\n declare ['constructor']: typeof LegacyPresenter\n declare scope: LegacyJsonApiDocument\n\n static type = 'object'\n static plural?: string\n static fields?: string[]\n\n constructor(scope?: JsonApiDocument) {\n // LegacyPresenter doesn't use the 'data' property, so pass an empty scope\n const emptyScope: JsonApiDocument = { data: null }\n super(scope || emptyScope)\n // Remove the 'data' property that the parent constructor adds\n if (!scope) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Need Partial to allow delete\n delete (this.scope as Partial<JsonApiDocument>).data\n }\n }\n\n pluralType(): string {\n return this.constructor.plural || this.constructor.type + 's'\n }\n\n attributes(instance: ModelLike | null): Record<string, unknown> {\n if (!instance) {\n return {}\n }\n const attributes = { ...this.constructor.adapter.get(instance) }\n const relationships = this.relationships()\n if (relationships) {\n for (const key in relationships) {\n let id: unknown\n const data = attributes[key]\n if (data == null) {\n id = attributes[key + 'Id']\n if (id != null) {\n attributes[key] = id\n }\n } else if (Array.isArray(data)) {\n attributes[key] = data.map((obj: unknown) => (hasId(obj) ? obj.id : obj))\n } else if (hasId(data)) {\n attributes[key] = data.id\n }\n }\n }\n\n // Include relationship keys in allowed fields (so users don't need to list them twice)\n const relationshipKeys = relationships ? Object.keys(relationships) : []\n const allowedFields = this.constructor.fields ? [...this.constructor.fields, ...relationshipKeys] : undefined\n\n return filterByFields(attributes, allowedFields)\n }\n\n includeRelationships(scope: LegacyJsonApiDocument, instance: ModelLike): unknown[] {\n if (!scope.links) {\n scope.links = {}\n }\n const relationships = this.relationships()\n const result: unknown[] = []\n\n if (!relationships) {\n return result\n }\n\n for (const key in relationships) {\n const factory = relationships[key]\n if (!factory) throw new Error(`Presenter for ${key} in ${this.constructor.type} is not defined`)\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Factory returns PresenterInstance, we know it's LegacyPresenter\n const presenter = new factory(scope) as LegacyPresenter\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- unknown from adapter.get\n const data = this.constructor.adapter.get(instance, key) as ModelLike | ModelLike[] | null\n if (data != null) {\n presenter.toJSON(data, { defaultPlural: true })\n }\n\n const type = scope[this.pluralType()] != null ? this.pluralType() : this.constructor.type\n const presenterType = presenter.constructor.type\n const keyName = scope[presenter.pluralType()] != null ? presenter.pluralType() : presenterType\n const link = { type: keyName }\n if (scope.links) {\n scope.links[`${type}.${key}`] = link\n }\n result.push(link)\n }\n return result\n }\n\n toJSON(\n instanceOrCollection: ModelLike | ModelLike[] | null | undefined,\n options?: LegacyPresenterOptions,\n ): LegacyJsonApiDocument {\n const opts = options ?? {}\n if (!this.scope.links) {\n this.scope.links = {}\n }\n if (Array.isArray(instanceOrCollection)) {\n const collection = instanceOrCollection\n const type = this.pluralType()\n if (!this.scope[type]) {\n this.scope[type] = []\n }\n collection.forEach((instance: ModelLike) => {\n return this.toJSON(instance)\n })\n } else {\n let links: JsonApiLinks | undefined\n const instance = instanceOrCollection\n let added = true\n const attrs = instance ? this.attributes(instance) : null\n if ((links = this.links())) {\n if (attrs) {\n attrs.links = links\n }\n }\n // If eg x.image already exists\n if (this.scope[this.constructor.type] && !this.scope[this.pluralType()]) {\n const existingValue = this.scope[this.constructor.type]\n if (attrs && hasId(existingValue) && existingValue.id !== attrs.id) {\n this.scope[this.pluralType()] = [this.scope[this.constructor.type]]\n delete this.scope[this.constructor.type]\n const pluralArray = this.scope[this.pluralType()]\n if (Array.isArray(pluralArray)) {\n pluralArray.push(attrs)\n }\n } else {\n added = false\n }\n\n // If eg x.images already exists\n } else if (this.scope[this.pluralType()]) {\n const existing = this.scope[this.pluralType()]\n if (Array.isArray(existing)) {\n if (attrs && !existing.some((i) => hasId(i) && i.id === attrs.id)) {\n existing.push(attrs)\n } else {\n added = false\n }\n }\n } else if (opts.defaultPlural) {\n this.scope[this.pluralType()] = attrs ? [attrs] : []\n } else {\n this.scope[this.constructor.type] = attrs\n }\n\n if (added && instance) {\n this.includeRelationships(this.scope, instance)\n }\n }\n return this.scope\n }\n\n payload(instance: ModelLike): LegacyJsonApiDocument {\n if (Array.isArray(instance)) {\n throw new Error('payload() expects a single resource, not an array')\n }\n if (instance == null) {\n throw new Error('payload() requires a resource, got null')\n }\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Legacy payload intentionally omits `data`\n return { [this.constructor.type]: this.attributes(instance) } as LegacyJsonApiDocument\n }\n\n render(instanceOrCollection: ModelLike | ModelLike[] | null): LegacyJsonApiDocument {\n return this.toJSON(instanceOrCollection)\n }\n\n static toJSON(\n instanceOrCollection: ModelLike | ModelLike[] | null,\n options?: LegacyPresenterOptions,\n ): LegacyJsonApiDocument {\n return new this().toJSON(instanceOrCollection, options)\n }\n\n static render(\n instanceOrCollection: ModelLike | ModelLike[] | null,\n _options?: LegacyPresenterOptions,\n ): LegacyJsonApiDocument {\n return new this().render(instanceOrCollection)\n }\n\n static payload(instance: ModelLike): LegacyJsonApiDocument {\n return new this().payload(instance)\n }\n }\n}\n","import type {\n StoreModel,\n StoreModelWithOptionalId,\n StoreModels,\n StoreResult,\n SchemaRegistry,\n ValidationError,\n InferModelType,\n LegacyStoreOptions,\n} from './types.js'\nimport { TYPE, LINKS, META } from './symbols.js'\nimport { validate } from './schema.js'\n\ninterface LegacyStoreRecordType {\n type: string\n data: Record<string, unknown> & {\n id?: string | number\n meta?: Record<string, unknown>\n links?: Record<string, unknown>\n }\n}\n\ninterface LegacyLinks {\n [key: string]: {\n type: string\n }\n}\n\ntype LegacyDataValue = Record<string, unknown> | Array<Record<string, unknown>>\n\nexport interface LegacyData {\n links?: LegacyLinks\n meta?: Record<string, unknown>\n [key: string]: LegacyDataValue | LegacyLinks | Record<string, unknown> | undefined\n}\n\nfunction hasId<T extends StoreModelWithOptionalId>(model: T): model is T & { id: string | number } {\n return model.id != null\n}\n\nexport default class LegacyStore<S extends SchemaRegistry = SchemaRegistry> {\n types: Record<string, string>\n records: LegacyStoreRecordType[]\n relations: Record<string, Record<string, string>>\n schemas?: S\n strict: boolean\n validationErrors: ValidationError[]\n models: StoreModels\n\n constructor(options?: LegacyStoreOptions<S>) {\n this.types = options?.types || {}\n this.schemas = options?.schemas\n this.strict = options?.strict ?? false\n this.records = []\n this.relations = {}\n this.validationErrors = []\n this.models = {}\n }\n\n reset(): void {\n this.records = []\n this.relations = {}\n this.validationErrors = []\n this.models = {}\n }\n\n #createStub(type: string, id: string): StoreModel {\n const stub: StoreModel = { id }\n stub[TYPE] = type\n return stub\n }\n\n #resolveRelationships(\n model: StoreModel | StoreModelWithOptionalId,\n type: string,\n resolver: (relationType: string, id: string) => StoreModel,\n ): void {\n const relations = this.relations[type]\n if (!relations) return\n\n for (const attribute in relations) {\n const relationType = relations[attribute]!\n const value = model[attribute]\n if (Array.isArray(value)) {\n model[attribute] = value\n .filter((id: unknown) => id != null)\n .map((id: unknown) => resolver(relationType, String(id)))\n } else if (value != null) {\n model[attribute] = resolver(relationType, String(value))\n } else {\n model[attribute] = null\n }\n }\n }\n\n #createModel(rec: LegacyStoreRecordType, type: string, options?: { models?: StoreModels }): StoreModelWithOptionalId {\n const models = options?.models\n\n const model: StoreModelWithOptionalId = { ...rec.data }\n if (rec.data.id != null) {\n model.id = rec.data.id\n }\n model[TYPE] = type\n if (rec.data.meta != null) {\n model[META] = rec.data.meta\n }\n if (rec.data.links != null) {\n model[LINKS] = rec.data.links\n }\n\n if (models && hasId(model)) {\n const idStr = String(model.id)\n if (!models[type]) {\n models[type] = {}\n }\n models[type]![idStr] = model\n }\n\n const resolver = (relationType: string, id: string): StoreModel => {\n return this.#findModel(relationType, id, models ?? {}) ?? this.#createStub(relationType, id)\n }\n this.#resolveRelationships(model, type, resolver)\n\n return model\n }\n\n toModel(rec: LegacyStoreRecordType, type: string, models: StoreModels): StoreModel {\n const idStr = String(rec.data.id)\n\n if (!models[type]) {\n models[type] = {}\n }\n\n if (models[type]![idStr]) {\n return models[type]![idStr]!\n }\n\n const result = this.#createModel(rec, type, { models })\n if (!hasId(result)) {\n throw new Error(`Expected model of type ${type} to have an id`)\n }\n const model = result\n\n if (this.schemas && this.schemas[type]) {\n const schema = this.schemas[type]\n const result = validate(schema, model, this.strict)\n\n if (!result.valid) {\n this.validationErrors.push({\n type,\n id: idStr,\n error: result.error,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Schema validation returns unknown, cast to StoreModel after validation\n const validatedModel = result.data as StoreModel\n\n // Preserve symbol keys from original model (schema validation may not preserve them)\n validatedModel[TYPE] = model[TYPE]\n validatedModel[LINKS] = model[LINKS]\n validatedModel[META] = model[META]\n\n models[type]![idStr] = validatedModel\n return validatedModel\n }\n\n return model\n }\n\n setupRelations(links: LegacyLinks): void {\n for (const key in links) {\n const value = links[key]!\n const parts = key.split('.')\n const typeRaw = parts[0]!\n const attribute = parts[1]!\n const type = this.types[typeRaw] || typeRaw\n if (!this.relations[type]) {\n this.relations[type] = {}\n }\n this.relations[type]![attribute] = this.types[value.type] || value.type\n }\n }\n\n findRecord(type: string, id: string): LegacyStoreRecordType | undefined {\n return this.records.find((r) => r.type === type && String(r.data.id) === id)\n }\n\n findRecords(type: string): LegacyStoreRecordType[] {\n return this.records.filter((r) => r.type === type)\n }\n\n #findModel(type: string, id: string, models: StoreModels): StoreModel | null {\n const rec = this.findRecord(type, id)\n if (rec == null) {\n return null\n }\n return models[type]?.[id] ?? this.toModel(rec, type, models)\n }\n\n static build(data: LegacyData): StoreModelWithOptionalId {\n return new LegacyStore().build(data)\n }\n\n build(data: LegacyData): StoreModelWithOptionalId {\n if (data.links) {\n this.setupRelations(data.links)\n }\n\n let name: string | undefined\n for (const key in data) {\n if (key !== 'meta' && key !== 'links') {\n name = key\n break\n }\n }\n\n if (name == null) {\n throw new Error('build() expects a single resource, not an array')\n }\n\n const value = data[name]\n if (value == null || Array.isArray(value)) {\n throw new Error('build() expects a single resource, not an array')\n }\n\n const type = this.types[name] || name\n return this.#createModel({ type, data: value }, type)\n }\n\n /** @deprecated Use retrieve() instead. */\n retrive<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null {\n return this.retrieve(type, data)\n }\n\n retrieve<T extends string>(type: T, data: LegacyData): InferModelType<S, T> | null {\n const synced = this.syncAll(data)\n const normalizedType = this.types[type] || type\n const model = synced.find((m) => m[TYPE] === normalizedType)\n if (!model) return null\n if (synced[META]) {\n model[META] = synced[META]\n }\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Enable type inference from type parameter\n return model as InferModelType<S, T>\n }\n\n find<T extends string>(type: T, id: string | number, models?: StoreModels): InferModelType<S, T> | null {\n const result = this.#findModel(type, String(id), models ?? this.models)\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type inference: maps string literal type parameter to schema type\n return result as InferModelType<S, T> | null\n }\n\n findAll<T extends string>(type: T, models?: StoreModels): InferModelType<S, T>[] {\n const modelsObj = models ?? this.models\n const recs = this.findRecords(type)\n if (recs.length === 0) {\n return []\n }\n recs.forEach((rec) => {\n if (!modelsObj[type]) {\n modelsObj[type] = {}\n }\n return this.toModel(rec, type, modelsObj)\n })\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Type inference: maps string literal type parameter to schema type\n return Object.values(modelsObj[type] || {}) as InferModelType<S, T>[]\n }\n\n remove(type: string, id?: string | number): void {\n const normalizedType = this.types[type] || type\n\n const removeOne = (record: LegacyStoreRecordType): void => {\n const index = this.records.indexOf(record)\n if (!(index < 0)) {\n this.records.splice(index, 1)\n }\n }\n\n if (id != null) {\n const idStr = String(id)\n const record = this.findRecord(normalizedType, idStr)\n if (record) {\n removeOne(record)\n }\n } else {\n const records = this.findRecords(normalizedType)\n records.forEach(removeOne)\n }\n }\n\n syncAll(data: LegacyData): StoreResult {\n // Clear validation errors and models cache from previous sync\n this.validationErrors = []\n this.models = {}\n\n if (data.links) {\n this.setupRelations(data.links)\n }\n\n const syncedRecords: LegacyStoreRecordType[] = []\n\n for (const name in data) {\n if (name === 'meta' || name === 'links') {\n continue\n }\n\n const value = data[name]!\n const type = this.types[name] || name\n\n const add = (d: Record<string, unknown>): void => {\n this.remove(type, String(d.id))\n const rec: LegacyStoreRecordType = { type, data: d }\n this.records.push(rec)\n syncedRecords.push(rec)\n }\n\n if (Array.isArray(value)) {\n value.forEach(add)\n } else if (typeof value === 'object' && value !== null) {\n add(value)\n }\n }\n\n for (const rec of syncedRecords) {\n this.toModel(rec, rec.type, this.models)\n }\n\n const result: StoreResult = syncedRecords.map((rec) => this.models[rec.type]![String(rec.data.id)]!)\n if (data.meta != null) {\n result[META] = data.meta\n }\n return result\n }\n\n sync(data: LegacyData): StoreModel | StoreResult {\n const result = this.syncAll(data)\n if (result.length === 1) {\n const model = result[0]\n if (result[META]) {\n model[META] = result[META]\n }\n return model\n }\n return result\n }\n\n retrieveAll<T extends string>(type: T, data: LegacyData): StoreResult<InferModelType<S, T>> {\n const normalizedType = this.types[type] || type\n const synced = this.syncAll(data)\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Enable type inference from type parameter\n const result: StoreResult<InferModelType<S, T>> = synced.filter(\n (model) => model[TYPE] === normalizedType,\n ) as StoreResult<InferModelType<S, T>>\n result[META] = synced[META]\n return result\n }\n}\n","import yaysonFactory from './yayson.js'\nimport createLegacyPresenter from './yayson/legacy-presenter.js'\nimport LegacyStore from './yayson/legacy-store.js'\nimport type { LegacyData } from './yayson/legacy-store.js'\nimport Adapter from './yayson/adapter.js'\nimport type {\n JsonApiDocument,\n JsonApiLink,\n JsonApiLinks,\n JsonApiRelationship,\n JsonApiRelationships,\n JsonApiResource,\n} from './yayson/types.js'\nimport type { YaysonOptions } from './yayson.js'\n\nexport type {\n Adapter,\n JsonApiDocument,\n JsonApiLink,\n JsonApiLinks,\n JsonApiRelationship,\n JsonApiRelationships,\n JsonApiResource,\n LegacyData,\n}\n\ninterface LegacyYaysonResult {\n Store: typeof LegacyStore\n Presenter: ReturnType<typeof createLegacyPresenter>\n Adapter: ReturnType<typeof yaysonFactory>['Adapter']\n}\n\nexport default function yayson(options?: YaysonOptions): LegacyYaysonResult {\n const { Presenter, Adapter } = yaysonFactory(options)\n return {\n Store: LegacyStore,\n Presenter: createLegacyPresenter(Presenter),\n Adapter,\n }\n}\n"],"mappings":";;;;AAKA,SAASA,QAAM,OAA0C;AACvD,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ;;AAQhE,SAAwB,sBAAsB,WAAsB;AAClE,QAAO,MAAM,wBAAwB,UAAU;EAI7C,OAAO,OAAO;EACd,OAAO;EACP,OAA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QAAQ,KAAK,OAAO,IAAI,MAAO,OAAO,IAAI,KAAK,GAAG,EAAG;AACpG,MAAI,KAAK,QAAQ,KACf,QAAO,QAAQ,KAAK;AAEtB,SAAO;;CAGT,KAAK,MAA4C;EAC/C,MAAM,SAAS,KAAK,QAAQ,KAAK;AACjC,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,QAAQ,OAAO;AACrB,OAAI,OAAO,MACT,OAAM,QAAQ,OAAO;AAEvB,UAAO;;AAET,SAAO;;CAGT,YAA8B,MAAS,MAAqD;EAC1F,MAAM,iBAAiB,KAAK,MAAM,SAAS;EAC3C,MAAM,SAAS,KAAK,QAAQ,KAAK;EAEjC,MAAM,SAA4C,OAAO,QACtD,UAAU,MAAM,UAAU,eAC5B;AACD,SAAO,QAAQ,OAAO;AACtB,SAAO;;;;;;ACnUX,SAAwB,OAAO,SAA6C;CAC1E,MAAM,EAAE,WAAW,YAAYK,eAAc,QAAQ;AACrD,QAAO;EACL,OAAO;EACP,WAAW,sBAAsB,UAAU;EAC3C;EACD"}
|
|
@@ -87,6 +87,13 @@ interface StoreModel extends Record<string, unknown> {
|
|
|
87
87
|
[REL_LINKS]?: JsonApiLink;
|
|
88
88
|
[REL_META]?: Record<string, unknown>;
|
|
89
89
|
}
|
|
90
|
+
/** Model type for create payloads where id may be absent */
|
|
91
|
+
interface StoreModelWithOptionalId extends Record<string, unknown> {
|
|
92
|
+
id?: string | number;
|
|
93
|
+
[TYPE]?: string;
|
|
94
|
+
[LINKS]?: JsonApiLink;
|
|
95
|
+
[META]?: Record<string, unknown>;
|
|
96
|
+
}
|
|
90
97
|
interface StoreModels {
|
|
91
98
|
[type: string]: {
|
|
92
99
|
[id: string]: StoreModel;
|
|
@@ -118,5 +125,5 @@ interface LegacyStoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
|
118
125
|
strict?: boolean;
|
|
119
126
|
}
|
|
120
127
|
//#endregion
|
|
121
|
-
export {
|
|
122
|
-
//# sourceMappingURL=types-
|
|
128
|
+
export { REL_META as C, ModelLike as E, REL_LINKS as S, Adapter as T, StoreResult as _, JsonApiRelationship as a, LINKS as b, LegacyPresenterOptions as c, SchemaRegistry as d, StoreModel as f, StoreRecord as g, StoreOptions as h, JsonApiLinks as i, LegacyStoreOptions as l, StoreModels as m, JsonApiDocument as n, JsonApiRelationships as o, StoreModelWithOptionalId as p, JsonApiLink as r, JsonApiResource as s, InferModelType as t, PresenterOptions as u, ValidationError as v, TYPE as w, META as x, ZodLikeSchema as y };
|
|
129
|
+
//# sourceMappingURL=types-Do2flKZX.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-Do2flKZX.d.mts","names":[],"sources":["../../../../../../yayson/adapter.ts","../../../../../../yayson/symbols.ts","../../../../../../yayson/schema.ts","../../../../../../yayson/types.ts"],"mappings":";KAAY,SAAA;AAAA,cAEN,OAAA;EAAA,OACG,GAAA,CAAI,KAAA,EAAO,SAAA,GAAY,MAAA;EAAA,OACvB,GAAA,CAAI,KAAA,EAAO,SAAA,EAAW,GAAA;EAAA,OAUtB,EAAA,CAAG,KAAA,EAAO,SAAA;AAAA;;;cCdN,IAAA;AAAA,cACA,KAAA;AAAA,cACA,IAAA;AAAA,cACA,SAAA;AAAA,cACA,QAAA;;;;ADJb;;;UEIiB,aAAA;EACf,KAAA,GAAQ,IAAA;EACR,SAAA,GAAY,IAAA;IAAoB,OAAA;IAAe,IAAA;EAAA;IAAoB,OAAA;IAAgB,KAAA;EAAA;AAAA;;;UCHpE,WAAA,SAAoB,MAAA;EACnC,IAAA;EACA,OAAA;AAAA;AAAA,UAGe,YAAA;EAAA,CACd,GAAA,WAAc,WAAA;AAAA;AAAA,UAGA,yBAAA;EACf,EAAA;EACA,IAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA,GAAO,yBAAA,GAA4B,yBAAA;EACnC,KAAA,GAAQ,WAAA;EACR,IAAA,GAAO,MAAA;AAAA;AAAA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AA,CAAgB,QAAA,CAAS,QAAA,KACzB,UAAA,GACF,UAAA;AAAA,UAEa,WAAA,KAAgB,UAAA,UAAoB,KAAA,CAAM,CAAA;EAAA,CACxD,IAAA,IAAQ,MAAA;AAAA;AAAA,UAGM,YAAA,WAAuB,cAAA,GAAiB,cAAA;EACvD,OAAA,GAAU,CAAA;EACV,MAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,EAAA;EACA,KAAA;AAAA;AAAA,UAGe,kBAAA,WAA6B,cAAA,GAAiB,cAAA;EAC7D,KAAA,GAAQ,MAAA;EACR,OAAA,GAAU,CAAA;EACV,MAAA;AAAA"}
|
|
@@ -87,6 +87,13 @@ interface StoreModel extends Record<string, unknown> {
|
|
|
87
87
|
[REL_LINKS]?: JsonApiLink;
|
|
88
88
|
[REL_META]?: Record<string, unknown>;
|
|
89
89
|
}
|
|
90
|
+
/** Model type for create payloads where id may be absent */
|
|
91
|
+
interface StoreModelWithOptionalId extends Record<string, unknown> {
|
|
92
|
+
id?: string | number;
|
|
93
|
+
[TYPE]?: string;
|
|
94
|
+
[LINKS]?: JsonApiLink;
|
|
95
|
+
[META]?: Record<string, unknown>;
|
|
96
|
+
}
|
|
90
97
|
interface StoreModels {
|
|
91
98
|
[type: string]: {
|
|
92
99
|
[id: string]: StoreModel;
|
|
@@ -118,5 +125,5 @@ interface LegacyStoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
|
118
125
|
strict?: boolean;
|
|
119
126
|
}
|
|
120
127
|
//#endregion
|
|
121
|
-
export {
|
|
122
|
-
//# sourceMappingURL=types-
|
|
128
|
+
export { REL_META as C, ModelLike as E, REL_LINKS as S, Adapter as T, StoreResult as _, JsonApiRelationship as a, LINKS as b, LegacyPresenterOptions as c, SchemaRegistry as d, StoreModel as f, StoreRecord as g, StoreOptions as h, JsonApiLinks as i, LegacyStoreOptions as l, StoreModels as m, JsonApiDocument as n, JsonApiRelationships as o, StoreModelWithOptionalId as p, JsonApiLink as r, JsonApiResource as s, InferModelType as t, PresenterOptions as u, ValidationError as v, TYPE as w, META as x, ZodLikeSchema as y };
|
|
129
|
+
//# sourceMappingURL=types-NiKV-lj-.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-NiKV-lj-.d.cts","names":[],"sources":["../../../../../../yayson/adapter.ts","../../../../../../yayson/symbols.ts","../../../../../../yayson/schema.ts","../../../../../../yayson/types.ts"],"mappings":";KAAY,SAAA;AAAA,cAEN,OAAA;EAAA,OACG,GAAA,CAAI,KAAA,EAAO,SAAA,GAAY,MAAA;EAAA,OACvB,GAAA,CAAI,KAAA,EAAO,SAAA,EAAW,GAAA;EAAA,OAUtB,EAAA,CAAG,KAAA,EAAO,SAAA;AAAA;;;cCdN,IAAA;AAAA,cACA,KAAA;AAAA,cACA,IAAA;AAAA,cACA,SAAA;AAAA,cACA,QAAA;;;;ADJb;;;UEIiB,aAAA;EACf,KAAA,GAAQ,IAAA;EACR,SAAA,GAAY,IAAA;IAAoB,OAAA;IAAe,IAAA;EAAA;IAAoB,OAAA;IAAgB,KAAA;EAAA;AAAA;;;UCHpE,WAAA,SAAoB,MAAA;EACnC,IAAA;EACA,OAAA;AAAA;AAAA,UAGe,YAAA;EAAA,CACd,GAAA,WAAc,WAAA;AAAA;AAAA,UAGA,yBAAA;EACf,EAAA;EACA,IAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA,GAAO,yBAAA,GAA4B,yBAAA;EACnC,KAAA,GAAQ,WAAA;EACR,IAAA,GAAO,MAAA;AAAA;AAAA,UAGQ,oBAAA;EAAA,CACd,GAAA,WAAc,mBAAA;AAAA;AAAA,UAGA,eAAA;EACf,EAAA;EACA,IAAA;EACA,UAAA,GAAa,MAAA;EACb,aAAA,GAAgB,oBAAA;EAChB,KAAA,GAAQ,WAAA;EACR,IAAA,GAAO,MAAA;AAAA;AAAA,UAGQ,eAAA;EACf,IAAA,EAAM,eAAA,GAAkB,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eAAA;EACf,IAAA;EACA,EAAA;EACA,KAAA;AAAA;AAAA,UAGe,kBAAA,WAA6B,cAAA,GAAiB,cAAA;EAC7D,KAAA,GAAQ,MAAA;EACR,OAAA,GAAU,CAAA;EACV,MAAA;AAAA"}
|
package/build/utils.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as REL_META, E as ModelLike, S as REL_LINKS, T as Adapter, b as LINKS, f as StoreModel, r as JsonApiLink, w as TYPE, x as META } from "./types-NiKV-lj-.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils.d.ts
|
|
4
4
|
declare function getType(model: StoreModel): string | undefined;
|
package/build/utils.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as REL_META, E as ModelLike, S as REL_LINKS, T as Adapter, b as LINKS, f as StoreModel, r as JsonApiLink, w as TYPE, x as META } from "./types-Do2flKZX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils.d.ts
|
|
4
4
|
declare function getType(model: StoreModel): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as ModelLike, T as Adapter, _ as StoreResult, d as SchemaRegistry, f as StoreModel, g as StoreRecord$1, h as StoreOptions, i as JsonApiLinks, m as StoreModels, n as JsonApiDocument, o as JsonApiRelationships, p as StoreModelWithOptionalId, r as JsonApiLink, t as InferModelType, u as PresenterOptions, v as ValidationError } from "./types-NiKV-lj-.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/yayson/presenter.d.ts
|
|
4
4
|
declare function createPresenter(adapter: typeof Adapter): {
|
|
@@ -14,6 +14,7 @@ declare function createPresenter(adapter: typeof Adapter): {
|
|
|
14
14
|
buildRelationships(instance: ModelLike | null): JsonApiRelationships | null;
|
|
15
15
|
buildSelfLink(instance: ModelLike): JsonApiLink | undefined;
|
|
16
16
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null | undefined, options?: PresenterOptions): JsonApiDocument;
|
|
17
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
17
18
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
18
19
|
};
|
|
19
20
|
adapter: typeof Adapter;
|
|
@@ -21,6 +22,7 @@ declare function createPresenter(adapter: typeof Adapter): {
|
|
|
21
22
|
fields?: string[];
|
|
22
23
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
23
24
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
25
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
24
26
|
};
|
|
25
27
|
type Presenter = ReturnType<typeof createPresenter>;
|
|
26
28
|
//#endregion
|
|
@@ -35,6 +37,7 @@ declare class StoreRecord implements StoreRecord$1 {
|
|
|
35
37
|
constructor(options: StoreRecord$1);
|
|
36
38
|
}
|
|
37
39
|
declare class Store<S extends SchemaRegistry = SchemaRegistry> {
|
|
40
|
+
#private;
|
|
38
41
|
records: StoreRecord[];
|
|
39
42
|
schemas?: S;
|
|
40
43
|
strict: boolean;
|
|
@@ -49,6 +52,15 @@ declare class Store<S extends SchemaRegistry = SchemaRegistry> {
|
|
|
49
52
|
remove(type: string, id?: string | number): void;
|
|
50
53
|
syncAll(body: JsonApiDocument): StoreResult;
|
|
51
54
|
sync(body: JsonApiDocument): StoreModel | StoreResult;
|
|
55
|
+
/**
|
|
56
|
+
* Build a model from a JSON:API document without storing it.
|
|
57
|
+
* Useful for create payloads where id may be absent.
|
|
58
|
+
*
|
|
59
|
+
* Per JSON:API spec: "The id member is not required when the resource object
|
|
60
|
+
* originates at the client and represents a new resource to be created on the server."
|
|
61
|
+
*/
|
|
62
|
+
static build(body: JsonApiDocument): StoreModelWithOptionalId;
|
|
63
|
+
build(body: JsonApiDocument): StoreModelWithOptionalId;
|
|
52
64
|
retrieve<T extends string>(type: T, body: JsonApiDocument): InferModelType<S, T> | null;
|
|
53
65
|
retrieveAll<T extends string>(type: T, body: JsonApiDocument): StoreResult<InferModelType<S, T>>;
|
|
54
66
|
}
|
|
@@ -66,4 +78,4 @@ interface YaysonResult {
|
|
|
66
78
|
declare function yayson(options?: YaysonOptions): YaysonResult;
|
|
67
79
|
//#endregion
|
|
68
80
|
export { Presenter as i, YaysonResult as n, yayson as r, YaysonOptions as t };
|
|
69
|
-
//# sourceMappingURL=yayson-
|
|
81
|
+
//# sourceMappingURL=yayson-3UYKq2H5.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yayson-3UYKq2H5.d.cts","names":[],"sources":["../../../../../../yayson/presenter.ts","../../../../../../yayson/store.ts","../../../../../../yayson.ts"],"mappings":";;;iBAyBwB,eAAA,CAAgB,OAAA,SAAgB,OAAA;EAAA,aAUhC,eAAA;iBAVe;WAQ5B,eAAA;iBAMM,SAAA;yBAIQ,SAAA,GAAY,WAAA;sBAIf,SAAA,GAAY,YAAA;qBAIb,MAAA,SAZJ;yBAgBQ,SAAA,UAAmB,MAAA;gCAiBZ,eAAA,EAAe,QAAA,EAAY,SAAA;iCAoB1B,SAAA,UAAmB,oBAAA;4BA0DxB,SAAA,GAAY,WAAA;iCAKZ,SAAA,GAAY,SAAA,uBAA8B,OAAA,GACtD,gBAAA,GACT,eAAA;sBA8Ee,SAAA,EAAS,OAAA,GAAY,gBAAA,GAAmB,eAAA;iCA0B7B,SAAA,GAAY,SAAA,WAAkB,OAAA,GAAY,gBAAA,GAAmB,eAAA;EAAA;;;;+BAItD,SAAA,GAAY,SAAA,WAAkB,OAAA,GAAY,gBAAA,GAAmB,eAAA;+BAI7D,SAAA,GAAY,SAAA,WAAkB,OAAA,GAAY,gBAAA,GAAmB,eAAA;oBAIxE,SAAA,EAAS,OAAA,GAAY,gBAAA,GAAmB,eAAA;AAAA;AAAA,KAQzD,SAAA,GAAY,UA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IAAA,EAAM,eAAA,GAAkB,WAAA,CAAY,cAAA,CAAe,CAAA,EAAG,CAAA;AAAA;;;KCzU1F,aAAA,mBAAgC,OAAA;AAAA,UAE3B,aAAA;EACR,OAAA,GAAU,aAAA;AAAA;AAAA,UAGF,YAAA;EACR,KAAA,SAAc,KAAA;EACd,SAAA,EAAW,SAAA;EACX,OAAA,SAAgB,OAAA;AAAA;AAAA,iBAgBT,MAAA,CAAO,OAAA,GAAU,aAAA,GAAgB,YAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as ModelLike, T as Adapter, _ as StoreResult, d as SchemaRegistry, f as StoreModel, g as StoreRecord$1, h as StoreOptions, i as JsonApiLinks, m as StoreModels, n as JsonApiDocument, o as JsonApiRelationships, p as StoreModelWithOptionalId, r as JsonApiLink, t as InferModelType, u as PresenterOptions, v as ValidationError } from "./types-Do2flKZX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/yayson/presenter.d.ts
|
|
4
4
|
declare function createPresenter(adapter: typeof Adapter): {
|
|
@@ -14,6 +14,7 @@ declare function createPresenter(adapter: typeof Adapter): {
|
|
|
14
14
|
buildRelationships(instance: ModelLike | null): JsonApiRelationships | null;
|
|
15
15
|
buildSelfLink(instance: ModelLike): JsonApiLink | undefined;
|
|
16
16
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null | undefined, options?: PresenterOptions): JsonApiDocument;
|
|
17
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
17
18
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
18
19
|
};
|
|
19
20
|
adapter: typeof Adapter;
|
|
@@ -21,6 +22,7 @@ declare function createPresenter(adapter: typeof Adapter): {
|
|
|
21
22
|
fields?: string[];
|
|
22
23
|
toJSON(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
23
24
|
render(instanceOrCollection: ModelLike | ModelLike[] | null, options?: PresenterOptions): JsonApiDocument;
|
|
25
|
+
payload(instance: ModelLike, options?: PresenterOptions): JsonApiDocument;
|
|
24
26
|
};
|
|
25
27
|
type Presenter = ReturnType<typeof createPresenter>;
|
|
26
28
|
//#endregion
|
|
@@ -35,6 +37,7 @@ declare class StoreRecord implements StoreRecord$1 {
|
|
|
35
37
|
constructor(options: StoreRecord$1);
|
|
36
38
|
}
|
|
37
39
|
declare class Store<S extends SchemaRegistry = SchemaRegistry> {
|
|
40
|
+
#private;
|
|
38
41
|
records: StoreRecord[];
|
|
39
42
|
schemas?: S;
|
|
40
43
|
strict: boolean;
|
|
@@ -49,6 +52,15 @@ declare class Store<S extends SchemaRegistry = SchemaRegistry> {
|
|
|
49
52
|
remove(type: string, id?: string | number): void;
|
|
50
53
|
syncAll(body: JsonApiDocument): StoreResult;
|
|
51
54
|
sync(body: JsonApiDocument): StoreModel | StoreResult;
|
|
55
|
+
/**
|
|
56
|
+
* Build a model from a JSON:API document without storing it.
|
|
57
|
+
* Useful for create payloads where id may be absent.
|
|
58
|
+
*
|
|
59
|
+
* Per JSON:API spec: "The id member is not required when the resource object
|
|
60
|
+
* originates at the client and represents a new resource to be created on the server."
|
|
61
|
+
*/
|
|
62
|
+
static build(body: JsonApiDocument): StoreModelWithOptionalId;
|
|
63
|
+
build(body: JsonApiDocument): StoreModelWithOptionalId;
|
|
52
64
|
retrieve<T extends string>(type: T, body: JsonApiDocument): InferModelType<S, T> | null;
|
|
53
65
|
retrieveAll<T extends string>(type: T, body: JsonApiDocument): StoreResult<InferModelType<S, T>>;
|
|
54
66
|
}
|
|
@@ -66,4 +78,4 @@ interface YaysonResult {
|
|
|
66
78
|
declare function yayson(options?: YaysonOptions): YaysonResult;
|
|
67
79
|
//#endregion
|
|
68
80
|
export { Presenter as i, YaysonResult as n, yayson as r, YaysonOptions as t };
|
|
69
|
-
//# sourceMappingURL=yayson-
|
|
81
|
+
//# sourceMappingURL=yayson-Ce5uGpgU.d.mts.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