yayson 3.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.
Files changed (57) hide show
  1. package/README.md +586 -67
  2. package/build/legacy.cjs +331 -0
  3. package/build/legacy.d.cts +113 -0
  4. package/build/legacy.d.cts.map +1 -0
  5. package/build/legacy.d.mts +113 -0
  6. package/build/legacy.d.mts.map +1 -0
  7. package/build/legacy.mjs +332 -0
  8. package/build/legacy.mjs.map +1 -0
  9. package/build/symbols-DSjKJ8vh.mjs +26 -0
  10. package/build/symbols-DSjKJ8vh.mjs.map +1 -0
  11. package/build/symbols-nFs99aEX.cjs +61 -0
  12. package/build/types-Do2flKZX.d.mts +129 -0
  13. package/build/types-Do2flKZX.d.mts.map +1 -0
  14. package/build/types-NiKV-lj-.d.cts +129 -0
  15. package/build/types-NiKV-lj-.d.cts.map +1 -0
  16. package/build/utils.cjs +31 -0
  17. package/build/utils.d.cts +11 -0
  18. package/build/utils.d.cts.map +1 -0
  19. package/build/utils.d.mts +11 -0
  20. package/build/utils.d.mts.map +1 -0
  21. package/build/utils.mjs +22 -0
  22. package/build/utils.mjs.map +1 -0
  23. package/build/yayson-3UYKq2H5.d.cts +81 -0
  24. package/build/yayson-3UYKq2H5.d.cts.map +1 -0
  25. package/build/yayson-Ce5uGpgU.d.mts +81 -0
  26. package/build/yayson-Ce5uGpgU.d.mts.map +1 -0
  27. package/build/yayson-CwZg5FNt.mjs +452 -0
  28. package/build/yayson-CwZg5FNt.mjs.map +1 -0
  29. package/build/yayson-l2JKseMH.cjs +468 -0
  30. package/build/yayson.cjs +3 -0
  31. package/build/yayson.d.cts +3 -0
  32. package/build/yayson.d.mts +3 -0
  33. package/build/yayson.mjs +3 -0
  34. package/package.json +72 -28
  35. package/skill/yayson/SKILL.md +233 -0
  36. package/skill/yayson/references/api.md +266 -0
  37. package/.eslintrc.json +0 -28
  38. package/.github/workflows/node.js.yml +0 -30
  39. package/.mocharc.js +0 -15
  40. package/.nvmrc +0 -1
  41. package/RELEASE.md +0 -3
  42. package/babel.config.json +0 -4
  43. package/legacy.js +0 -2
  44. package/prettier.config.js +0 -5
  45. package/src/legacy.js +0 -14
  46. package/src/yayson/adapter.js +0 -18
  47. package/src/yayson/adapters/index.js +0 -1
  48. package/src/yayson/adapters/sequelize.js +0 -11
  49. package/src/yayson/legacy-presenter.js +0 -121
  50. package/src/yayson/legacy-store.js +0 -156
  51. package/src/yayson/presenter.js +0 -198
  52. package/src/yayson/store.js +0 -194
  53. package/src/yayson.js +0 -23
  54. package/tags +0 -59
  55. package/webpack.browser.js +0 -27
  56. package/webpack.common.js +0 -39
  57. package/webpack.dist.js +0 -21
@@ -0,0 +1,468 @@
1
+ const require_symbols = require('./symbols-nFs99aEX.cjs');
2
+
3
+ //#region src/yayson/adapters/sequelize.ts
4
+ function isSequelizeModel(model) {
5
+ return model != null && typeof model === "object" && "get" in model && typeof model.get === "function";
6
+ }
7
+ var SequelizeAdapter = class extends require_symbols.adapter_default {
8
+ static get(model, key) {
9
+ if (isSequelizeModel(model)) return model.get(key);
10
+ }
11
+ static id(model) {
12
+ const pkFields = model.constructor && "primaryKeys" in model.constructor ? Object.keys(model.constructor.primaryKeys) : ["id"];
13
+ if (pkFields.length > 1) throw new Error("YAYSON does not support Sequelize models with composite primary keys. You can only use one column for your primary key. Currently using: " + pkFields.join(","));
14
+ else if (pkFields.length < 1) throw new Error("YAYSON can only serialize Sequelize models which have a primary key. This is used for the JSON:API model id.");
15
+ const id = this.get(model, pkFields[0]);
16
+ if (id == null) return;
17
+ return `${id}`;
18
+ }
19
+ };
20
+ var sequelize_default = SequelizeAdapter;
21
+
22
+ //#endregion
23
+ //#region src/yayson/utils.ts
24
+ /**
25
+ * Filters an attributes object to only include keys in the fields array.
26
+ * Returns the original attributes if fields is undefined.
27
+ */
28
+ function filterByFields(attributes, fields) {
29
+ if (!fields) return attributes;
30
+ const filtered = {};
31
+ for (const key of fields) if (key in attributes) filtered[key] = attributes[key];
32
+ return filtered;
33
+ }
34
+
35
+ //#endregion
36
+ //#region src/yayson/presenter.ts
37
+ function buildLinks(link) {
38
+ if (link == null) return;
39
+ if (typeof link === "object" && (link.self != null || link.related != null)) return link;
40
+ else return { self: String(link) };
41
+ }
42
+ function createPresenter(adapter) {
43
+ class Presenter {
44
+ static adapter = adapter;
45
+ static type = "objects";
46
+ static fields;
47
+ scope;
48
+ constructor(scope) {
49
+ this.scope = scope ?? { data: null };
50
+ }
51
+ id(instance) {
52
+ return this.constructor.adapter.id(instance);
53
+ }
54
+ selfLinks(_instance) {}
55
+ links(_instance) {}
56
+ relationships() {
57
+ return {};
58
+ }
59
+ attributes(instance) {
60
+ if (instance == null) return {};
61
+ const attributes = { ...this.constructor.adapter.get(instance) };
62
+ delete attributes["id"];
63
+ const relationships = this.relationships();
64
+ if (relationships) for (const key in relationships) delete attributes[key];
65
+ return filterByFields(attributes, this.constructor.fields);
66
+ }
67
+ includeRelationships(scope, instance) {
68
+ const relationships = this.relationships();
69
+ const result = [];
70
+ if (!relationships) return result;
71
+ for (const key in relationships) {
72
+ const factory = relationships[key];
73
+ if (!factory) throw new Error(`Presenter for ${key} in ${this.constructor.type} is not defined`);
74
+ const presenter = new factory(scope);
75
+ const data = this.constructor.adapter.get(instance, key);
76
+ result.push(presenter.toJSON(data, { include: true }));
77
+ }
78
+ return result;
79
+ }
80
+ buildRelationships(instance) {
81
+ if (instance == null) return null;
82
+ const rels = this.relationships();
83
+ const links = this.links(instance) || {};
84
+ let relationships = null;
85
+ if (!rels) return null;
86
+ for (const key in rels) {
87
+ const data = this.constructor.adapter.get(instance, key);
88
+ const presenter = rels[key];
89
+ const buildData = (d) => {
90
+ const id = this.constructor.adapter.id(d);
91
+ if (!id) throw new Error(`Model of type ${presenter.type} is missing an id (relationship '${key}' of ${this.constructor.type})`);
92
+ return {
93
+ id,
94
+ type: presenter.type
95
+ };
96
+ };
97
+ const build = (d) => {
98
+ const rel = {};
99
+ if (d != null) rel.data = buildData(d);
100
+ if (links[key] != null) rel.links = buildLinks(links[key]);
101
+ else if (d == null) rel.data = null;
102
+ return rel;
103
+ };
104
+ if (!relationships) relationships = {};
105
+ if (!relationships[key]) relationships[key] = {};
106
+ if (Array.isArray(data)) {
107
+ relationships[key].data = data.map(buildData);
108
+ if (links[key] != null) relationships[key].links = buildLinks(links[key]);
109
+ } else relationships[key] = build(data);
110
+ }
111
+ return relationships;
112
+ }
113
+ buildSelfLink(instance) {
114
+ return buildLinks(this.selfLinks(instance));
115
+ }
116
+ toJSON(instanceOrCollection, options) {
117
+ const opts = options ?? {};
118
+ if (opts.meta != null) this.scope.meta = opts.meta;
119
+ if (opts.links != null) this.scope.links = opts.links;
120
+ if (!this.scope.data) this.scope.data = null;
121
+ if (instanceOrCollection == null) return this.scope;
122
+ if (Array.isArray(instanceOrCollection)) {
123
+ const collection = instanceOrCollection;
124
+ if (!this.scope.data) this.scope.data = [];
125
+ collection.forEach((instance) => {
126
+ return this.toJSON(instance, options);
127
+ });
128
+ } else {
129
+ const instance = instanceOrCollection;
130
+ let added = true;
131
+ const model = {
132
+ id: this.id(instance),
133
+ type: this.constructor.type,
134
+ attributes: this.attributes(instance)
135
+ };
136
+ if (model.id === void 0) delete model.id;
137
+ const relationships = this.buildRelationships(instance);
138
+ if (relationships != null) model.relationships = relationships;
139
+ const links = this.buildSelfLink(instance);
140
+ if (links != null) model.links = links;
141
+ if (opts.include) {
142
+ if (!this.scope.included) this.scope.included = [];
143
+ if (!(this.scope.included || []).concat(Array.isArray(this.scope.data) ? this.scope.data : this.scope.data ? [this.scope.data] : []).some((i) => i.id === model.id && i.type === model.type)) this.scope.included.push(model);
144
+ else added = false;
145
+ } else if (this.scope.data != null) if (Array.isArray(this.scope.data)) if (!this.scope.data.some((i) => i.id === model.id && i.type === model.type)) this.scope.data.push(model);
146
+ else added = false;
147
+ else this.scope.data = model;
148
+ else this.scope.data = model;
149
+ if (added) this.includeRelationships(this.scope, instance);
150
+ }
151
+ return this.scope;
152
+ }
153
+ payload(instance, options) {
154
+ if (Array.isArray(instance)) throw new Error("payload() expects a single resource, not an array");
155
+ if (instance == null) throw new Error("payload() requires a resource, got null");
156
+ const model = {
157
+ type: this.constructor.type,
158
+ attributes: this.attributes(instance)
159
+ };
160
+ const id = this.id(instance);
161
+ if (id != null) model.id = id;
162
+ const relationships = this.buildRelationships(instance);
163
+ if (relationships != null) model.relationships = relationships;
164
+ const result = { data: model };
165
+ const opts = options ?? {};
166
+ if (opts.meta != null) result.meta = opts.meta;
167
+ if (opts.links != null) result.links = opts.links;
168
+ return result;
169
+ }
170
+ render(instanceOrCollection, options) {
171
+ return this.toJSON(instanceOrCollection, options);
172
+ }
173
+ static toJSON(instanceOrCollection, options) {
174
+ return new this().toJSON(instanceOrCollection, options);
175
+ }
176
+ static render(instanceOrCollection, options) {
177
+ return new this().render(instanceOrCollection, options);
178
+ }
179
+ static payload(instance, options) {
180
+ return new this().payload(instance, options);
181
+ }
182
+ }
183
+ return Presenter;
184
+ }
185
+
186
+ //#endregion
187
+ //#region src/yayson/schema.ts
188
+ function isZodLikeSchema(schema) {
189
+ return schema != null && typeof schema === "object" && "parse" in schema && typeof schema.parse === "function" && "safeParse" in schema && typeof schema.safeParse === "function";
190
+ }
191
+ function validate(schema, data, strict) {
192
+ if (!isZodLikeSchema(schema)) throw new Error("Invalid schema: must have parse and safeParse methods");
193
+ if (strict) return {
194
+ valid: true,
195
+ data: schema.parse(data)
196
+ };
197
+ else {
198
+ const result = schema.safeParse(data);
199
+ if (result.success) return {
200
+ valid: true,
201
+ data: result.data
202
+ };
203
+ else return {
204
+ valid: false,
205
+ data,
206
+ error: result.error
207
+ };
208
+ }
209
+ }
210
+
211
+ //#endregion
212
+ //#region src/yayson/store.ts
213
+ function hasId(model) {
214
+ return model.id != null;
215
+ }
216
+ var StoreRecord = class {
217
+ id;
218
+ type;
219
+ attributes;
220
+ relationships;
221
+ links;
222
+ meta;
223
+ constructor(options) {
224
+ this.id = options.id;
225
+ this.type = options.type;
226
+ this.attributes = options.attributes;
227
+ this.relationships = options.relationships;
228
+ this.links = options.links;
229
+ this.meta = options.meta;
230
+ }
231
+ };
232
+ var Store = class Store {
233
+ records = [];
234
+ schemas;
235
+ strict;
236
+ validationErrors = [];
237
+ constructor(options) {
238
+ this.schemas = options?.schemas;
239
+ this.strict = options?.strict ?? false;
240
+ this.reset();
241
+ }
242
+ reset() {
243
+ this.records = [];
244
+ this.validationErrors = [];
245
+ }
246
+ #createStub(type, id) {
247
+ const stub = { id };
248
+ stub[require_symbols.TYPE] = type;
249
+ return stub;
250
+ }
251
+ #createModel(resource, options) {
252
+ const models = options?.models ?? {};
253
+ const model = { ...resource.attributes || {} };
254
+ if (resource.id != null) model.id = resource.id;
255
+ const type = resource.type;
256
+ model[require_symbols.TYPE] = type;
257
+ if (resource.meta != null) model[require_symbols.META] = resource.meta;
258
+ if (resource.links != null) model[require_symbols.LINKS] = resource.links;
259
+ if (hasId(model)) {
260
+ const idStr = String(model.id);
261
+ if (!models[type]) models[type] = {};
262
+ if (!models[type][idStr]) models[type][idStr] = model;
263
+ }
264
+ if (resource.relationships != null) {
265
+ const resolver = (ref) => {
266
+ return this.#findModel(ref.type, ref.id, models) ?? this.#createStub(ref.type, ref.id);
267
+ };
268
+ this.#resolveRelationships(model, resource.relationships, resolver, { includeRelMeta: options?.includeRelMeta });
269
+ }
270
+ return model;
271
+ }
272
+ #resolveRelationships(model, relationships, resolver, options) {
273
+ const includeRelMeta = options?.includeRelMeta ?? true;
274
+ for (const key in relationships) {
275
+ const { data, links, meta } = relationships[key];
276
+ model[key] = null;
277
+ if (data == null && links == null) continue;
278
+ if (Array.isArray(data)) model[key] = data.filter((item) => item.id != null).map(resolver);
279
+ else if (data != null && data.id != null) {
280
+ const relModel = resolver(data);
281
+ if (includeRelMeta) {
282
+ const modelWithMeta = relModel;
283
+ modelWithMeta[require_symbols.REL_LINKS] = links || {};
284
+ modelWithMeta[require_symbols.REL_META] = meta || {};
285
+ }
286
+ model[key] = relModel;
287
+ } else if (data == null && (links != null || meta != null) && includeRelMeta) {
288
+ const relModel = { id: "" };
289
+ relModel[require_symbols.REL_LINKS] = links || {};
290
+ relModel[require_symbols.REL_META] = meta || {};
291
+ model[key] = relModel;
292
+ }
293
+ }
294
+ }
295
+ toModel(rec, type, models) {
296
+ const model = this.#createModel(rec, { models });
297
+ if (this.schemas && this.schemas[rec.type]) {
298
+ const schema = this.schemas[rec.type];
299
+ const result = validate(schema, model, this.strict);
300
+ if (!result.valid) this.validationErrors.push({
301
+ type: rec.type,
302
+ id: rec.id,
303
+ error: result.error
304
+ });
305
+ const validatedModel = result.data;
306
+ validatedModel[require_symbols.TYPE] = model[require_symbols.TYPE];
307
+ validatedModel[require_symbols.LINKS] = model[require_symbols.LINKS];
308
+ validatedModel[require_symbols.META] = model[require_symbols.META];
309
+ return validatedModel;
310
+ }
311
+ return model;
312
+ }
313
+ findRecord(type, id) {
314
+ const idStr = String(id);
315
+ return this.records.find((r) => r.type === type && String(r.id) === idStr);
316
+ }
317
+ findRecords(type) {
318
+ return this.records.filter((r) => r.type === type);
319
+ }
320
+ #findModel(type, id, models) {
321
+ const idStr = String(id);
322
+ const cached = models[type]?.[idStr];
323
+ if (cached) return cached;
324
+ const rec = this.findRecord(type, id);
325
+ if (rec == null) return null;
326
+ return this.toModel(rec, type, models);
327
+ }
328
+ find(type, id, models) {
329
+ return this.#findModel(type, id, models ?? {});
330
+ }
331
+ findAll(type, models) {
332
+ const modelsObj = models ?? {};
333
+ const recs = this.findRecords(type);
334
+ if (recs == null) return [];
335
+ recs.forEach((rec) => {
336
+ if (!modelsObj[type]) modelsObj[type] = {};
337
+ return this.toModel(rec, type, modelsObj);
338
+ });
339
+ return Object.values(modelsObj[type] || {});
340
+ }
341
+ remove(type, id) {
342
+ const removeOne = (record) => {
343
+ const index = this.records.indexOf(record);
344
+ if (!(index < 0)) this.records.splice(index, 1);
345
+ };
346
+ if (id != null) {
347
+ const record = this.findRecord(type, String(id));
348
+ if (record) removeOne(record);
349
+ } else this.findRecords(type).forEach(removeOne);
350
+ }
351
+ syncAll(body) {
352
+ this.validationErrors = [];
353
+ const previousRecords = [...this.records];
354
+ const syncData = (data) => {
355
+ if (data == null) return [];
356
+ const add = (obj) => {
357
+ const { type, id } = obj;
358
+ this.remove(type, id);
359
+ const rec = new StoreRecord(obj);
360
+ this.records.push(rec);
361
+ return rec;
362
+ };
363
+ if (Array.isArray(data)) return data.map((item) => {
364
+ if (!item.id) throw new Error(`Resource of type ${item.type} is missing an id`);
365
+ return add({
366
+ ...item,
367
+ attributes: item.attributes ?? void 0,
368
+ relationships: item.relationships ?? void 0,
369
+ id: item.id
370
+ });
371
+ });
372
+ else {
373
+ if (!data.id) throw new Error(`Resource of type ${data.type} is missing an id`);
374
+ return [add({
375
+ ...data,
376
+ attributes: data.attributes ?? void 0,
377
+ relationships: data.relationships ?? void 0,
378
+ id: data.id
379
+ })];
380
+ }
381
+ };
382
+ try {
383
+ syncData(body.included);
384
+ const recs = syncData(body.data);
385
+ const models = {};
386
+ const result = recs.map((rec) => this.toModel(rec, rec.type, models));
387
+ if (body.meta != null) result[require_symbols.META] = body.meta;
388
+ return result;
389
+ } catch (e) {
390
+ this.records = previousRecords;
391
+ throw e;
392
+ }
393
+ }
394
+ sync(body) {
395
+ const result = this.syncAll(body);
396
+ if (!Array.isArray(body.data) && body.data != null) {
397
+ const model = result[0];
398
+ if (result[require_symbols.META]) model[require_symbols.META] = result[require_symbols.META];
399
+ return model;
400
+ }
401
+ return result;
402
+ }
403
+ /**
404
+ * Build a model from a JSON:API document without storing it.
405
+ * Useful for create payloads where id may be absent.
406
+ *
407
+ * Per JSON:API spec: "The id member is not required when the resource object
408
+ * originates at the client and represents a new resource to be created on the server."
409
+ */
410
+ static build(body) {
411
+ return new Store().build(body);
412
+ }
413
+ build(body) {
414
+ const { data } = body;
415
+ if (data == null || Array.isArray(data)) throw new Error("build() expects a single resource in data, not null or an array");
416
+ return this.#createModel(data);
417
+ }
418
+ retrieve(type, body) {
419
+ const synced = this.syncAll(body);
420
+ const model = synced.find((m) => m[require_symbols.TYPE] === type);
421
+ if (!model) return null;
422
+ if (synced[require_symbols.META]) model[require_symbols.META] = synced[require_symbols.META];
423
+ return model;
424
+ }
425
+ retrieveAll(type, body) {
426
+ const synced = this.syncAll(body);
427
+ const result = synced.filter((model) => model[require_symbols.TYPE] === type);
428
+ result[require_symbols.META] = synced[require_symbols.META];
429
+ return result;
430
+ }
431
+ };
432
+
433
+ //#endregion
434
+ //#region src/yayson.ts
435
+ function lookupAdapter(nameOrAdapter) {
436
+ if (nameOrAdapter === "default" || !nameOrAdapter) return require_symbols.adapter_default;
437
+ else if (typeof nameOrAdapter === "string") if (nameOrAdapter === "sequelize") return sequelize_default;
438
+ else throw new Error("Adapter not found: " + nameOrAdapter);
439
+ return nameOrAdapter;
440
+ }
441
+ function yayson(options) {
442
+ return {
443
+ Store,
444
+ Presenter: createPresenter(lookupAdapter(options?.adapter)),
445
+ Adapter: require_symbols.adapter_default
446
+ };
447
+ }
448
+ var yayson_default = yayson;
449
+
450
+ //#endregion
451
+ Object.defineProperty(exports, 'filterByFields', {
452
+ enumerable: true,
453
+ get: function () {
454
+ return filterByFields;
455
+ }
456
+ });
457
+ Object.defineProperty(exports, 'validate', {
458
+ enumerable: true,
459
+ get: function () {
460
+ return validate;
461
+ }
462
+ });
463
+ Object.defineProperty(exports, 'yayson_default', {
464
+ enumerable: true,
465
+ get: function () {
466
+ return yayson_default;
467
+ }
468
+ });
@@ -0,0 +1,3 @@
1
+ const require_yayson = require('./yayson-l2JKseMH.cjs');
2
+
3
+ module.exports = require_yayson.yayson_default;
@@ -0,0 +1,3 @@
1
+ import { T as Adapter, a as JsonApiRelationship, d as SchemaRegistry, h as StoreOptions, i as JsonApiLinks, l as LegacyStoreOptions, n as JsonApiDocument, o as JsonApiRelationships, r as JsonApiLink, s as JsonApiResource, u as PresenterOptions, v as ValidationError, y as ZodLikeSchema } from "./types-NiKV-lj-.cjs";
2
+ import { n as YaysonResult, r as yayson, t as YaysonOptions } from "./yayson-3UYKq2H5.cjs";
3
+ export { Adapter, JsonApiDocument, JsonApiLink, JsonApiLinks, JsonApiRelationship, JsonApiRelationships, JsonApiResource, LegacyStoreOptions, PresenterOptions, SchemaRegistry, StoreOptions, ValidationError, YaysonOptions, YaysonResult, ZodLikeSchema, yayson as default };
@@ -0,0 +1,3 @@
1
+ import { T as Adapter, a as JsonApiRelationship, d as SchemaRegistry, h as StoreOptions, i as JsonApiLinks, l as LegacyStoreOptions, n as JsonApiDocument, o as JsonApiRelationships, r as JsonApiLink, s as JsonApiResource, u as PresenterOptions, v as ValidationError, y as ZodLikeSchema } from "./types-Do2flKZX.mjs";
2
+ import { n as YaysonResult, r as yayson, t as YaysonOptions } from "./yayson-Ce5uGpgU.mjs";
3
+ export { Adapter, JsonApiDocument, JsonApiLink, JsonApiLinks, JsonApiRelationship, JsonApiRelationships, JsonApiResource, LegacyStoreOptions, PresenterOptions, SchemaRegistry, StoreOptions, ValidationError, YaysonOptions, YaysonResult, ZodLikeSchema, yayson as default };
@@ -0,0 +1,3 @@
1
+ import { t as yayson_default } from "./yayson-CwZg5FNt.mjs";
2
+
3
+ export { yayson_default as default };
package/package.json CHANGED
@@ -1,19 +1,63 @@
1
1
  {
2
2
  "name": "yayson",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "A library for serializing and reading JSON API standardized data in JavaScript.",
5
- "main": "src/yayson.js",
5
+ "type": "module",
6
+ "main": "./build/yayson.cjs",
7
+ "module": "./build/yayson.mjs",
8
+ "types": "./build/yayson.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./build/yayson.d.mts",
13
+ "default": "./build/yayson.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./build/yayson.d.cts",
17
+ "default": "./build/yayson.cjs"
18
+ }
19
+ },
20
+ "./legacy": {
21
+ "import": {
22
+ "types": "./build/legacy.d.mts",
23
+ "default": "./build/legacy.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./build/legacy.d.cts",
27
+ "default": "./build/legacy.cjs"
28
+ }
29
+ },
30
+ "./utils": {
31
+ "import": {
32
+ "types": "./build/utils.d.mts",
33
+ "default": "./build/utils.mjs"
34
+ },
35
+ "require": {
36
+ "types": "./build/utils.d.cts",
37
+ "default": "./build/utils.cjs"
38
+ }
39
+ }
40
+ },
41
+ "files": [
42
+ "build/**/*",
43
+ "skill/**/*",
44
+ "README.md",
45
+ "LICENSE"
46
+ ],
6
47
  "engines": {
7
- "node": ">=14",
8
- "npm": ">=6"
48
+ "node": ">=20",
49
+ "npm": ">=10"
9
50
  },
10
51
  "scripts": {
11
- "test": "mocha",
12
- "build": "webpack --config webpack.dist.js",
13
- "test-browser": "webpack-dev-server --config webpack.browser.js",
14
- "preversion": "npm test && npm run build && git add dist/yayson.js",
52
+ "test": "tsx node_modules/.bin/mocha",
53
+ "test:build": "node test/build.test.cjs",
54
+ "build": "tsdown",
55
+ "prepublishOnly": "npm run build && npm run test:build",
56
+ "preversion": "npm test && npm run build && npm run test:build",
15
57
  "postversion": "git push --follow-tags origin master",
16
- "release": "npm version minor"
58
+ "release": "npm version minor",
59
+ "format": "prettier --write src test",
60
+ "lint": "concurrently --prefix '[{name}]' --prefix-colors '#f73fae,#00c2db,#00db8b' --names 'tsc,eslint,prettier' 'tsc --noEmit' 'eslint .' 'prettier --check .'"
17
61
  },
18
62
  "repository": {
19
63
  "type": "git",
@@ -37,26 +81,26 @@
37
81
  "url": "https://github.com/confetti/yayson/issues"
38
82
  },
39
83
  "homepage": "https://github.com/confetti/yayson",
40
- "browserslist": [
41
- "defaults",
42
- "not IE 11"
43
- ],
44
84
  "devDependencies": {
45
- "@babel/core": "^7.20.12",
46
- "@babel/eslint-parser": "^7.19.1",
47
- "@babel/preset-env": "^7.20.2",
48
- "babel-loader": "^9.1.2",
49
- "chai": "^4.3.7",
50
- "core-js": "^3.27.2",
51
- "eslint": "^8.33.0",
52
- "eslint-plugin-mocha": "^10.1.0",
53
- "mocha": "^10.2.0",
54
- "prettier": "^2.8.3",
55
- "sinon": "^15.0.1",
85
+ "@eslint-community/eslint-plugin-eslint-comments": "4.6.0",
86
+ "@eslint/js": "^9.35.0",
87
+ "@types/mocha": "^10.0.10",
88
+ "@types/node": "^24.5.1",
89
+ "@types/sinon": "^17.0.4",
90
+ "@types/sinon-chai": "^4.0.0",
91
+ "chai": "^4.5.0",
92
+ "concurrently": "^9.2.1",
93
+ "eslint": "9.39.1",
94
+ "eslint-plugin-mocha": "^11.1.0",
95
+ "globals": "^16.4.0",
96
+ "mocha": "^11.7.2",
97
+ "prettier": "3.7.2",
98
+ "sinon": "^21.0.0",
56
99
  "sinon-chai": "^3.7.0",
57
- "webpack": "^5.75.0",
58
- "webpack-cli": "^5.0.1",
59
- "webpack-dev-server": "^4.11.1",
60
- "webpack-merge": "^5.8.0"
100
+ "tsdown": "0.20.0-beta.4",
101
+ "tsx": "^4.20.5",
102
+ "typescript": "^5.9.2",
103
+ "typescript-eslint": "^8.44.0",
104
+ "zod": "4.3.5"
61
105
  }
62
106
  }