yayson 3.0.0 → 4.0.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 +440 -68
- package/build/legacy.cjs +278 -0
- package/build/legacy.d.cts +105 -0
- package/build/legacy.d.cts.map +1 -0
- package/build/legacy.d.mts +105 -0
- package/build/legacy.d.mts.map +1 -0
- package/build/legacy.mjs +279 -0
- package/build/legacy.mjs.map +1 -0
- package/build/symbols-DSjKJ8vh.mjs +26 -0
- package/build/symbols-DSjKJ8vh.mjs.map +1 -0
- package/build/symbols-nFs99aEX.cjs +61 -0
- package/build/types-BsfPiPEw.d.mts +122 -0
- package/build/types-BsfPiPEw.d.mts.map +1 -0
- package/build/types-DbMIe8E2.d.cts +122 -0
- package/build/types-DbMIe8E2.d.cts.map +1 -0
- package/build/utils.cjs +31 -0
- package/build/utils.d.cts +11 -0
- package/build/utils.d.cts.map +1 -0
- package/build/utils.d.mts +11 -0
- package/build/utils.d.mts.map +1 -0
- package/build/utils.mjs +22 -0
- package/build/utils.mjs.map +1 -0
- package/build/yayson-BJv2Z0Z6.mjs +391 -0
- package/build/yayson-BJv2Z0Z6.mjs.map +1 -0
- package/build/yayson-BKEyEcGk.d.cts +69 -0
- package/build/yayson-BKEyEcGk.d.cts.map +1 -0
- package/build/yayson-CRbukIqr.d.mts +69 -0
- package/build/yayson-CRbukIqr.d.mts.map +1 -0
- package/build/yayson-CUfrxK9d.cjs +407 -0
- package/build/yayson.cjs +3 -0
- package/build/yayson.d.cts +3 -0
- package/build/yayson.d.mts +3 -0
- package/build/yayson.mjs +3 -0
- package/package.json +72 -28
- package/skill/yayson/SKILL.md +233 -0
- package/skill/yayson/references/api.md +266 -0
- package/.eslintrc.json +0 -28
- package/.github/workflows/node.js.yml +0 -30
- package/.mocharc.js +0 -15
- package/.nvmrc +0 -1
- package/RELEASE.md +0 -3
- package/babel.config.json +0 -4
- package/legacy.js +0 -2
- package/prettier.config.js +0 -5
- package/src/legacy.js +0 -14
- package/src/yayson/adapter.js +0 -18
- package/src/yayson/adapters/index.js +0 -1
- package/src/yayson/adapters/sequelize.js +0 -11
- package/src/yayson/legacy-presenter.js +0 -121
- package/src/yayson/legacy-store.js +0 -156
- package/src/yayson/presenter.js +0 -198
- package/src/yayson/store.js +0 -194
- package/src/yayson.js +0 -23
- package/tags +0 -59
- package/webpack.browser.js +0 -27
- package/webpack.common.js +0 -39
- package/webpack.dist.js +0 -21
package/build/legacy.mjs
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
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-BJv2Z0Z6.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/yayson/legacy-presenter.ts
|
|
5
|
+
function hasId(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && "id" in value;
|
|
7
|
+
}
|
|
8
|
+
function createLegacyPresenter(Presenter) {
|
|
9
|
+
return class LegacyPresenter extends Presenter {
|
|
10
|
+
static type = "object";
|
|
11
|
+
static plural;
|
|
12
|
+
static fields;
|
|
13
|
+
constructor(scope) {
|
|
14
|
+
super(scope || { data: null });
|
|
15
|
+
if (!scope) delete this.scope.data;
|
|
16
|
+
}
|
|
17
|
+
pluralType() {
|
|
18
|
+
return this.constructor.plural || this.constructor.type + "s";
|
|
19
|
+
}
|
|
20
|
+
attributes(instance) {
|
|
21
|
+
if (!instance) return {};
|
|
22
|
+
const attributes = { ...this.constructor.adapter.get(instance) };
|
|
23
|
+
const relationships = this.relationships();
|
|
24
|
+
if (relationships) for (const key in relationships) {
|
|
25
|
+
let id;
|
|
26
|
+
const data = attributes[key];
|
|
27
|
+
if (data == null) {
|
|
28
|
+
id = attributes[key + "Id"];
|
|
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;
|
|
32
|
+
}
|
|
33
|
+
const relationshipKeys = relationships ? Object.keys(relationships) : [];
|
|
34
|
+
return filterByFields(attributes, this.constructor.fields ? [...this.constructor.fields, ...relationshipKeys] : void 0);
|
|
35
|
+
}
|
|
36
|
+
includeRelationships(scope, instance) {
|
|
37
|
+
if (!scope.links) scope.links = {};
|
|
38
|
+
const relationships = this.relationships();
|
|
39
|
+
const result = [];
|
|
40
|
+
if (!relationships) return result;
|
|
41
|
+
for (const key in relationships) {
|
|
42
|
+
const factory = relationships[key];
|
|
43
|
+
if (!factory) throw new Error(`Presenter for ${key} in ${this.constructor.type} is not defined`);
|
|
44
|
+
const presenter = new factory(scope);
|
|
45
|
+
const data = this.constructor.adapter.get(instance, key);
|
|
46
|
+
if (data != null) presenter.toJSON(data, { defaultPlural: true });
|
|
47
|
+
const type = scope[this.pluralType()] != null ? this.pluralType() : this.constructor.type;
|
|
48
|
+
const presenterType = presenter.constructor.type;
|
|
49
|
+
const link = { type: scope[presenter.pluralType()] != null ? presenter.pluralType() : presenterType };
|
|
50
|
+
if (scope.links) scope.links[`${type}.${key}`] = link;
|
|
51
|
+
result.push(link);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
toJSON(instanceOrCollection, options) {
|
|
56
|
+
const opts = options ?? {};
|
|
57
|
+
if (!this.scope.links) this.scope.links = {};
|
|
58
|
+
if (Array.isArray(instanceOrCollection)) {
|
|
59
|
+
const collection = instanceOrCollection;
|
|
60
|
+
const type = this.pluralType();
|
|
61
|
+
if (!this.scope[type]) this.scope[type] = [];
|
|
62
|
+
collection.forEach((instance) => {
|
|
63
|
+
return this.toJSON(instance);
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
let links;
|
|
67
|
+
const instance = instanceOrCollection;
|
|
68
|
+
let added = true;
|
|
69
|
+
const attrs = instance ? this.attributes(instance) : null;
|
|
70
|
+
if (links = this.links()) {
|
|
71
|
+
if (attrs) attrs.links = links;
|
|
72
|
+
}
|
|
73
|
+
if (this.scope[this.constructor.type] && !this.scope[this.pluralType()]) {
|
|
74
|
+
const existingValue = this.scope[this.constructor.type];
|
|
75
|
+
if (attrs && hasId(existingValue) && existingValue.id !== attrs.id) {
|
|
76
|
+
this.scope[this.pluralType()] = [this.scope[this.constructor.type]];
|
|
77
|
+
delete this.scope[this.constructor.type];
|
|
78
|
+
const pluralArray = this.scope[this.pluralType()];
|
|
79
|
+
if (Array.isArray(pluralArray)) pluralArray.push(attrs);
|
|
80
|
+
} else added = false;
|
|
81
|
+
} else if (this.scope[this.pluralType()]) {
|
|
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);
|
|
84
|
+
else added = false;
|
|
85
|
+
} else if (opts.defaultPlural) this.scope[this.pluralType()] = attrs ? [attrs] : [];
|
|
86
|
+
else this.scope[this.constructor.type] = attrs;
|
|
87
|
+
if (added && instance) this.includeRelationships(this.scope, instance);
|
|
88
|
+
}
|
|
89
|
+
return this.scope;
|
|
90
|
+
}
|
|
91
|
+
render(instanceOrCollection) {
|
|
92
|
+
return this.toJSON(instanceOrCollection);
|
|
93
|
+
}
|
|
94
|
+
static toJSON(instanceOrCollection, options) {
|
|
95
|
+
return new this().toJSON(instanceOrCollection, options);
|
|
96
|
+
}
|
|
97
|
+
static render(instanceOrCollection, _options) {
|
|
98
|
+
return new this().render(instanceOrCollection);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/yayson/legacy-store.ts
|
|
105
|
+
var LegacyStore = class {
|
|
106
|
+
types;
|
|
107
|
+
records;
|
|
108
|
+
relations;
|
|
109
|
+
schemas;
|
|
110
|
+
strict;
|
|
111
|
+
validationErrors;
|
|
112
|
+
models;
|
|
113
|
+
constructor(options) {
|
|
114
|
+
this.types = options?.types || {};
|
|
115
|
+
this.schemas = options?.schemas;
|
|
116
|
+
this.strict = options?.strict ?? false;
|
|
117
|
+
this.records = [];
|
|
118
|
+
this.relations = {};
|
|
119
|
+
this.validationErrors = [];
|
|
120
|
+
this.models = {};
|
|
121
|
+
}
|
|
122
|
+
reset() {
|
|
123
|
+
this.records = [];
|
|
124
|
+
this.relations = {};
|
|
125
|
+
this.validationErrors = [];
|
|
126
|
+
this.models = {};
|
|
127
|
+
}
|
|
128
|
+
toModel(rec, type, models) {
|
|
129
|
+
const idStr = String(rec.data.id);
|
|
130
|
+
if (!models[type]) models[type] = {};
|
|
131
|
+
if (models[type][idStr]) return models[type][idStr];
|
|
132
|
+
const model = {
|
|
133
|
+
...rec.data,
|
|
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;
|
|
140
|
+
const relations = this.relations[type];
|
|
141
|
+
if (relations) for (const attribute in relations) {
|
|
142
|
+
const relationType = relations[attribute];
|
|
143
|
+
const value = model[attribute];
|
|
144
|
+
model[attribute] = Array.isArray(value) ? value.map((id) => this.find(relationType, String(id), models)) : this.find(relationType, String(value), models);
|
|
145
|
+
}
|
|
146
|
+
if (this.schemas && this.schemas[type]) {
|
|
147
|
+
const schema = this.schemas[type];
|
|
148
|
+
const result = validate(schema, model, this.strict);
|
|
149
|
+
if (!result.valid) this.validationErrors.push({
|
|
150
|
+
type,
|
|
151
|
+
id: idStr,
|
|
152
|
+
error: result.error
|
|
153
|
+
});
|
|
154
|
+
const validatedModel = result.data;
|
|
155
|
+
validatedModel[TYPE] = model[TYPE];
|
|
156
|
+
validatedModel[LINKS] = model[LINKS];
|
|
157
|
+
validatedModel[META] = model[META];
|
|
158
|
+
models[type][idStr] = validatedModel;
|
|
159
|
+
return validatedModel;
|
|
160
|
+
}
|
|
161
|
+
return model;
|
|
162
|
+
}
|
|
163
|
+
setupRelations(links) {
|
|
164
|
+
for (const key in links) {
|
|
165
|
+
const value = links[key];
|
|
166
|
+
const parts = key.split(".");
|
|
167
|
+
const typeRaw = parts[0];
|
|
168
|
+
const attribute = parts[1];
|
|
169
|
+
const type = this.types[typeRaw] || typeRaw;
|
|
170
|
+
if (!this.relations[type]) this.relations[type] = {};
|
|
171
|
+
this.relations[type][attribute] = this.types[value.type] || value.type;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
findRecord(type, id) {
|
|
175
|
+
return this.records.find((r) => r.type === type && String(r.data.id) === id);
|
|
176
|
+
}
|
|
177
|
+
findRecords(type) {
|
|
178
|
+
return this.records.filter((r) => r.type === type);
|
|
179
|
+
}
|
|
180
|
+
/** @deprecated Use retrieve() instead. */
|
|
181
|
+
retrive(type, data) {
|
|
182
|
+
return this.retrieve(type, data);
|
|
183
|
+
}
|
|
184
|
+
retrieve(type, data) {
|
|
185
|
+
const synced = this.syncAll(data);
|
|
186
|
+
const normalizedType = this.types[type] || type;
|
|
187
|
+
const model = synced.find((m) => m[TYPE] === normalizedType);
|
|
188
|
+
if (!model) return null;
|
|
189
|
+
if (synced[META]) model[META] = synced[META];
|
|
190
|
+
return model;
|
|
191
|
+
}
|
|
192
|
+
find(type, id, models) {
|
|
193
|
+
const modelsObj = models ?? this.models;
|
|
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);
|
|
199
|
+
}
|
|
200
|
+
findAll(type, models) {
|
|
201
|
+
const modelsObj = models ?? this.models;
|
|
202
|
+
const recs = this.findRecords(type);
|
|
203
|
+
if (recs.length === 0) return [];
|
|
204
|
+
recs.forEach((rec) => {
|
|
205
|
+
if (!modelsObj[type]) modelsObj[type] = {};
|
|
206
|
+
return this.toModel(rec, type, modelsObj);
|
|
207
|
+
});
|
|
208
|
+
return Object.values(modelsObj[type] || {});
|
|
209
|
+
}
|
|
210
|
+
remove(type, id) {
|
|
211
|
+
const normalizedType = this.types[type] || type;
|
|
212
|
+
const removeOne = (record) => {
|
|
213
|
+
const index = this.records.indexOf(record);
|
|
214
|
+
if (!(index < 0)) this.records.splice(index, 1);
|
|
215
|
+
};
|
|
216
|
+
if (id != null) {
|
|
217
|
+
const idStr = String(id);
|
|
218
|
+
const record = this.findRecord(normalizedType, idStr);
|
|
219
|
+
if (record) removeOne(record);
|
|
220
|
+
} else this.findRecords(normalizedType).forEach(removeOne);
|
|
221
|
+
}
|
|
222
|
+
syncAll(data) {
|
|
223
|
+
this.validationErrors = [];
|
|
224
|
+
this.models = {};
|
|
225
|
+
if (data.links) this.setupRelations(data.links);
|
|
226
|
+
const syncedRecords = [];
|
|
227
|
+
for (const name in data) {
|
|
228
|
+
if (name === "meta" || name === "links") continue;
|
|
229
|
+
const value = data[name];
|
|
230
|
+
const type = this.types[name] || name;
|
|
231
|
+
const add = (d) => {
|
|
232
|
+
this.remove(type, String(d.id));
|
|
233
|
+
const rec = {
|
|
234
|
+
type,
|
|
235
|
+
data: d
|
|
236
|
+
};
|
|
237
|
+
this.records.push(rec);
|
|
238
|
+
syncedRecords.push(rec);
|
|
239
|
+
};
|
|
240
|
+
if (Array.isArray(value)) value.forEach(add);
|
|
241
|
+
else if (typeof value === "object" && value !== null) add(value);
|
|
242
|
+
}
|
|
243
|
+
for (const rec of syncedRecords) this.toModel(rec, rec.type, this.models);
|
|
244
|
+
const result = syncedRecords.map((rec) => this.models[rec.type][String(rec.data.id)]);
|
|
245
|
+
if (data.meta != null) result[META] = data.meta;
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
sync(data) {
|
|
249
|
+
const result = this.syncAll(data);
|
|
250
|
+
if (result.length === 1) {
|
|
251
|
+
const model = result[0];
|
|
252
|
+
if (result[META]) model[META] = result[META];
|
|
253
|
+
return model;
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
retrieveAll(type, data) {
|
|
258
|
+
const normalizedType = this.types[type] || type;
|
|
259
|
+
const synced = this.syncAll(data);
|
|
260
|
+
const result = synced.filter((model) => model[TYPE] === normalizedType);
|
|
261
|
+
result[META] = synced[META];
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/legacy.ts
|
|
268
|
+
function yayson(options) {
|
|
269
|
+
const { Presenter, Adapter } = yayson_default(options);
|
|
270
|
+
return {
|
|
271
|
+
Store: LegacyStore,
|
|
272
|
+
Presenter: createLegacyPresenter(Presenter),
|
|
273
|
+
Adapter
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
export { yayson as default };
|
|
279
|
+
//# sourceMappingURL=legacy.mjs.map
|
|
@@ -0,0 +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: L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AQ,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;;;;;;AC3PX,SAAwB,OAAO,SAA6C;CAC1E,MAAM,EAAE,WAAW,YAAYA,eAAc,QAAQ;AACrD,QAAO;EACL,OAAO;EACP,WAAW,sBAAsB,UAAU;EAC3C;EACD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/yayson/adapter.ts
|
|
2
|
+
var Adapter = class {
|
|
3
|
+
static get(model, key) {
|
|
4
|
+
const obj = model;
|
|
5
|
+
if (key) return obj[key];
|
|
6
|
+
return obj;
|
|
7
|
+
}
|
|
8
|
+
static id(model) {
|
|
9
|
+
const id = this.get(model, "id");
|
|
10
|
+
if (id == null) return;
|
|
11
|
+
return `${id}`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var adapter_default = Adapter;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/yayson/symbols.ts
|
|
18
|
+
const TYPE = Symbol("yayson.type");
|
|
19
|
+
const LINKS = Symbol("yayson.links");
|
|
20
|
+
const META = Symbol("yayson.meta");
|
|
21
|
+
const REL_LINKS = Symbol("yayson.rel-links");
|
|
22
|
+
const REL_META = Symbol("yayson.rel-meta");
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { TYPE as a, REL_META as i, META as n, adapter_default as o, REL_LINKS as r, LINKS as t };
|
|
26
|
+
//# sourceMappingURL=symbols-DSjKJ8vh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbols-DSjKJ8vh.mjs","names":[],"sources":["../src/yayson/adapter.ts","../src/yayson/symbols.ts"],"sourcesContent":["export type ModelLike = object\n\nclass Adapter {\n static get(model: ModelLike): Record<string, unknown>\n static get(model: ModelLike, key: string): unknown\n static get(model: ModelLike, key?: string): unknown {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- ModelLike is object for flexibility, cast for dynamic access\n const obj = model as Record<string, unknown>\n if (key) {\n return obj[key]\n }\n return obj\n }\n\n static id(model: ModelLike): string | undefined {\n const id = this.get(model, 'id')\n if (id == null) {\n return undefined\n }\n return `${id}`\n }\n}\n\nexport default Adapter\n","export const TYPE: unique symbol = Symbol('yayson.type')\nexport const LINKS: unique symbol = Symbol('yayson.links')\nexport const META: unique symbol = Symbol('yayson.meta')\nexport const REL_LINKS: unique symbol = Symbol('yayson.rel-links')\nexport const REL_META: unique symbol = Symbol('yayson.rel-meta')\n"],"mappings":";AAEA,IAAM,UAAN,MAAc;CAGZ,OAAO,IAAI,OAAkB,KAAuB;EAElD,MAAM,MAAM;AACZ,MAAI,IACF,QAAO,IAAI;AAEb,SAAO;;CAGT,OAAO,GAAG,OAAsC;EAC9C,MAAM,KAAK,KAAK,IAAI,OAAO,KAAK;AAChC,MAAI,MAAM,KACR;AAEF,SAAO,GAAG;;;AAId,sBAAe;;;;ACvBf,MAAa,OAAsB,OAAO,cAAc;AACxD,MAAa,QAAuB,OAAO,eAAe;AAC1D,MAAa,OAAsB,OAAO,cAAc;AACxD,MAAa,YAA2B,OAAO,mBAAmB;AAClE,MAAa,WAA0B,OAAO,kBAAkB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/yayson/adapter.ts
|
|
3
|
+
var Adapter = class {
|
|
4
|
+
static get(model, key) {
|
|
5
|
+
const obj = model;
|
|
6
|
+
if (key) return obj[key];
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
static id(model) {
|
|
10
|
+
const id = this.get(model, "id");
|
|
11
|
+
if (id == null) return;
|
|
12
|
+
return `${id}`;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var adapter_default = Adapter;
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/yayson/symbols.ts
|
|
19
|
+
const TYPE = Symbol("yayson.type");
|
|
20
|
+
const LINKS = Symbol("yayson.links");
|
|
21
|
+
const META = Symbol("yayson.meta");
|
|
22
|
+
const REL_LINKS = Symbol("yayson.rel-links");
|
|
23
|
+
const REL_META = Symbol("yayson.rel-meta");
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
Object.defineProperty(exports, 'LINKS', {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return LINKS;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, 'META', {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return META;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, 'REL_LINKS', {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return REL_LINKS;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, 'REL_META', {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return REL_META;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, 'TYPE', {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return TYPE;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, 'adapter_default', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return adapter_default;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//#region src/yayson/adapter.d.ts
|
|
2
|
+
type ModelLike = object;
|
|
3
|
+
declare class Adapter {
|
|
4
|
+
static get(model: ModelLike): Record<string, unknown>;
|
|
5
|
+
static get(model: ModelLike, key: string): unknown;
|
|
6
|
+
static id(model: ModelLike): string | undefined;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/yayson/symbols.d.ts
|
|
10
|
+
declare const TYPE: unique symbol;
|
|
11
|
+
declare const LINKS: unique symbol;
|
|
12
|
+
declare const META: unique symbol;
|
|
13
|
+
declare const REL_LINKS: unique symbol;
|
|
14
|
+
declare const REL_META: unique symbol;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/yayson/schema.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Interface for Zod-like schema objects.
|
|
19
|
+
* Any schema library that implements `parse` and `safeParse` methods will work.
|
|
20
|
+
*/
|
|
21
|
+
interface ZodLikeSchema {
|
|
22
|
+
parse: (data: unknown) => unknown;
|
|
23
|
+
safeParse: (data: unknown) => {
|
|
24
|
+
success: true;
|
|
25
|
+
data: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
success: false;
|
|
28
|
+
error: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/yayson/types.d.ts
|
|
33
|
+
interface JsonApiLink extends Record<string, unknown> {
|
|
34
|
+
self?: string;
|
|
35
|
+
related?: string;
|
|
36
|
+
}
|
|
37
|
+
interface JsonApiLinks {
|
|
38
|
+
[key: string]: JsonApiLink | string | undefined;
|
|
39
|
+
}
|
|
40
|
+
interface JsonApiResourceIdentifier {
|
|
41
|
+
id: string | number;
|
|
42
|
+
type: string;
|
|
43
|
+
}
|
|
44
|
+
interface JsonApiRelationship {
|
|
45
|
+
data?: JsonApiResourceIdentifier | JsonApiResourceIdentifier[] | null;
|
|
46
|
+
links?: JsonApiLink;
|
|
47
|
+
meta?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
interface JsonApiRelationships {
|
|
50
|
+
[key: string]: JsonApiRelationship;
|
|
51
|
+
}
|
|
52
|
+
interface JsonApiResource {
|
|
53
|
+
id?: string | number;
|
|
54
|
+
type: string;
|
|
55
|
+
attributes?: Record<string, unknown> | null;
|
|
56
|
+
relationships?: JsonApiRelationships | null;
|
|
57
|
+
links?: JsonApiLink;
|
|
58
|
+
meta?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
interface JsonApiDocument {
|
|
61
|
+
data: JsonApiResource | JsonApiResource[] | null;
|
|
62
|
+
included?: JsonApiResource[];
|
|
63
|
+
links?: JsonApiLinks;
|
|
64
|
+
meta?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
interface PresenterOptions {
|
|
67
|
+
meta?: Record<string, unknown>;
|
|
68
|
+
links?: JsonApiLinks;
|
|
69
|
+
include?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface LegacyPresenterOptions extends PresenterOptions {
|
|
72
|
+
defaultPlural?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface StoreRecord {
|
|
75
|
+
id: string | number;
|
|
76
|
+
type: string;
|
|
77
|
+
attributes?: Record<string, unknown>;
|
|
78
|
+
relationships?: JsonApiRelationships;
|
|
79
|
+
links?: JsonApiLink;
|
|
80
|
+
meta?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
interface StoreModel extends Record<string, unknown> {
|
|
83
|
+
id: string | number;
|
|
84
|
+
[TYPE]?: string;
|
|
85
|
+
[LINKS]?: JsonApiLink;
|
|
86
|
+
[META]?: Record<string, unknown>;
|
|
87
|
+
[REL_LINKS]?: JsonApiLink;
|
|
88
|
+
[REL_META]?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
interface StoreModels {
|
|
91
|
+
[type: string]: {
|
|
92
|
+
[id: string]: StoreModel;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface SchemaRegistry {
|
|
96
|
+
[type: string]: ZodLikeSchema;
|
|
97
|
+
}
|
|
98
|
+
type InferSchemaType<Schema> = Schema extends {
|
|
99
|
+
parse: (data: unknown) => infer ParsedType;
|
|
100
|
+
safeParse: (data: unknown) => unknown;
|
|
101
|
+
} ? ParsedType : unknown;
|
|
102
|
+
type InferModelType<Registry, TypeName extends string> = Registry extends SchemaRegistry ? TypeName extends keyof Registry ? InferSchemaType<Registry[TypeName]> : StoreModel : StoreModel;
|
|
103
|
+
interface StoreResult<T = StoreModel> extends Array<T> {
|
|
104
|
+
[META]?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
interface StoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
107
|
+
schemas?: S;
|
|
108
|
+
strict?: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface ValidationError {
|
|
111
|
+
type: string;
|
|
112
|
+
id: string | number;
|
|
113
|
+
error: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface LegacyStoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
116
|
+
types?: Record<string, string>;
|
|
117
|
+
schemas?: S;
|
|
118
|
+
strict?: boolean;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { TYPE as C, REL_META as S, ModelLike as T, ValidationError as _, JsonApiRelationship as a, META as b, LegacyPresenterOptions as c, SchemaRegistry as d, StoreModel as f, StoreResult as g, StoreRecord as h, JsonApiLinks as i, LegacyStoreOptions as l, StoreOptions as m, JsonApiDocument as n, JsonApiRelationships as o, StoreModels as p, JsonApiLink as r, JsonApiResource as s, InferModelType as t, PresenterOptions as u, ZodLikeSchema as v, Adapter as w, REL_LINKS as x, LINKS as y };
|
|
122
|
+
//# sourceMappingURL=types-BsfPiPEw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BsfPiPEw.d.mts","names":[],"sources":["../../../../../../yayson/adapter.ts","../../../../../../yayson/symbols.ts","../../../../../../yayson/schema.ts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MAAA;EACb,aAAA,GAAgB,oBAAA;EAChB,KAAA,GAAQ,WAAA;EACR,IAAA,GAAO,MAAA;AAAA;AAAA,UAGQ,UAAA,SAAmB,MAAA;EAClC,EAAA;EAAA,CACC,IAAA;EAAA,CACA,KAAA,IAAS,WAAA;EAAA,CACT,IAAA,IAAQ,MAAA;EAAA,CACR,SAAA,IAAa,WAAA;EAAA,CACb,QAAA,IAAY,MAAA;AAAA;AAAA,UAGE,WAAA;EAAA,CACd,IAAA;IAAA,CACE,EAAA,WAAa,UAAA;EAAA;AAAA;AAAA,UAID,cAAA;EAAA,CACd,IAAA,WAAe,aAAA;AAAA;AAAA,KAIN,eAAA,WAA0B,MAAA;EACpC,KAAA,GAAQ,IAAA;EACR,SAAA,GAAY,IAAA;AAAA,IAEV,UAAA;AAAA,KAGQ,cAAA,sCAAoD,QAAA,SAAiB,cAAA,GAC7E,QAAA,eAAuB,QAAA,GACrB,eAAA,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"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//#region src/yayson/adapter.d.ts
|
|
2
|
+
type ModelLike = object;
|
|
3
|
+
declare class Adapter {
|
|
4
|
+
static get(model: ModelLike): Record<string, unknown>;
|
|
5
|
+
static get(model: ModelLike, key: string): unknown;
|
|
6
|
+
static id(model: ModelLike): string | undefined;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/yayson/symbols.d.ts
|
|
10
|
+
declare const TYPE: unique symbol;
|
|
11
|
+
declare const LINKS: unique symbol;
|
|
12
|
+
declare const META: unique symbol;
|
|
13
|
+
declare const REL_LINKS: unique symbol;
|
|
14
|
+
declare const REL_META: unique symbol;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/yayson/schema.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Interface for Zod-like schema objects.
|
|
19
|
+
* Any schema library that implements `parse` and `safeParse` methods will work.
|
|
20
|
+
*/
|
|
21
|
+
interface ZodLikeSchema {
|
|
22
|
+
parse: (data: unknown) => unknown;
|
|
23
|
+
safeParse: (data: unknown) => {
|
|
24
|
+
success: true;
|
|
25
|
+
data: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
success: false;
|
|
28
|
+
error: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/yayson/types.d.ts
|
|
33
|
+
interface JsonApiLink extends Record<string, unknown> {
|
|
34
|
+
self?: string;
|
|
35
|
+
related?: string;
|
|
36
|
+
}
|
|
37
|
+
interface JsonApiLinks {
|
|
38
|
+
[key: string]: JsonApiLink | string | undefined;
|
|
39
|
+
}
|
|
40
|
+
interface JsonApiResourceIdentifier {
|
|
41
|
+
id: string | number;
|
|
42
|
+
type: string;
|
|
43
|
+
}
|
|
44
|
+
interface JsonApiRelationship {
|
|
45
|
+
data?: JsonApiResourceIdentifier | JsonApiResourceIdentifier[] | null;
|
|
46
|
+
links?: JsonApiLink;
|
|
47
|
+
meta?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
interface JsonApiRelationships {
|
|
50
|
+
[key: string]: JsonApiRelationship;
|
|
51
|
+
}
|
|
52
|
+
interface JsonApiResource {
|
|
53
|
+
id?: string | number;
|
|
54
|
+
type: string;
|
|
55
|
+
attributes?: Record<string, unknown> | null;
|
|
56
|
+
relationships?: JsonApiRelationships | null;
|
|
57
|
+
links?: JsonApiLink;
|
|
58
|
+
meta?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
interface JsonApiDocument {
|
|
61
|
+
data: JsonApiResource | JsonApiResource[] | null;
|
|
62
|
+
included?: JsonApiResource[];
|
|
63
|
+
links?: JsonApiLinks;
|
|
64
|
+
meta?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
interface PresenterOptions {
|
|
67
|
+
meta?: Record<string, unknown>;
|
|
68
|
+
links?: JsonApiLinks;
|
|
69
|
+
include?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface LegacyPresenterOptions extends PresenterOptions {
|
|
72
|
+
defaultPlural?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface StoreRecord {
|
|
75
|
+
id: string | number;
|
|
76
|
+
type: string;
|
|
77
|
+
attributes?: Record<string, unknown>;
|
|
78
|
+
relationships?: JsonApiRelationships;
|
|
79
|
+
links?: JsonApiLink;
|
|
80
|
+
meta?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
interface StoreModel extends Record<string, unknown> {
|
|
83
|
+
id: string | number;
|
|
84
|
+
[TYPE]?: string;
|
|
85
|
+
[LINKS]?: JsonApiLink;
|
|
86
|
+
[META]?: Record<string, unknown>;
|
|
87
|
+
[REL_LINKS]?: JsonApiLink;
|
|
88
|
+
[REL_META]?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
interface StoreModels {
|
|
91
|
+
[type: string]: {
|
|
92
|
+
[id: string]: StoreModel;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface SchemaRegistry {
|
|
96
|
+
[type: string]: ZodLikeSchema;
|
|
97
|
+
}
|
|
98
|
+
type InferSchemaType<Schema> = Schema extends {
|
|
99
|
+
parse: (data: unknown) => infer ParsedType;
|
|
100
|
+
safeParse: (data: unknown) => unknown;
|
|
101
|
+
} ? ParsedType : unknown;
|
|
102
|
+
type InferModelType<Registry, TypeName extends string> = Registry extends SchemaRegistry ? TypeName extends keyof Registry ? InferSchemaType<Registry[TypeName]> : StoreModel : StoreModel;
|
|
103
|
+
interface StoreResult<T = StoreModel> extends Array<T> {
|
|
104
|
+
[META]?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
interface StoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
107
|
+
schemas?: S;
|
|
108
|
+
strict?: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface ValidationError {
|
|
111
|
+
type: string;
|
|
112
|
+
id: string | number;
|
|
113
|
+
error: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface LegacyStoreOptions<S extends SchemaRegistry = SchemaRegistry> {
|
|
116
|
+
types?: Record<string, string>;
|
|
117
|
+
schemas?: S;
|
|
118
|
+
strict?: boolean;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { TYPE as C, REL_META as S, ModelLike as T, ValidationError as _, JsonApiRelationship as a, META as b, LegacyPresenterOptions as c, SchemaRegistry as d, StoreModel as f, StoreResult as g, StoreRecord as h, JsonApiLinks as i, LegacyStoreOptions as l, StoreOptions as m, JsonApiDocument as n, JsonApiRelationships as o, StoreModels as p, JsonApiLink as r, JsonApiResource as s, InferModelType as t, PresenterOptions as u, ZodLikeSchema as v, Adapter as w, REL_LINKS as x, LINKS as y };
|
|
122
|
+
//# sourceMappingURL=types-DbMIe8E2.d.cts.map
|