@jay-framework/data-files 0.23.1 → 0.24.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/dist/index.d.ts CHANGED
@@ -119,13 +119,9 @@ declare function clearSchemaCache(): void;
119
119
  declare function resolveReferences(row: DataRow, tags: SchemaTag[], contentDir: string, visited?: Set<string>, depth?: number): Promise<Record<string, unknown>>;
120
120
  declare function clearFileCache(): void;
121
121
 
122
- interface GeneratedContract {
123
- name: string;
124
- yaml: string;
125
- }
126
- declare function generateDataPagesContract(): AsyncGenerator<GeneratedContract>;
127
- declare function generateDataListContract(): AsyncGenerator<GeneratedContract>;
128
- declare function generateDataItemContract(): AsyncGenerator<GeneratedContract>;
122
+ declare const generateDataPagesContract: _jay_framework_fullstack_component.DynamicContractGenerator<[]>;
123
+ declare const generateDataListContract: _jay_framework_fullstack_component.DynamicContractGenerator<[]>;
124
+ declare const generateDataItemContract: _jay_framework_fullstack_component.DynamicContractGenerator<[]>;
129
125
 
130
126
  declare function generateSchema(contentDir: string): Promise<string>;
131
127
  declare function generateSchemaCommand(args: string[]): Promise<void>;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { makeJayStackComponent, notFound, phaseOutput } from "@jay-framework/fullstack-component";
4
+ import { makeJayStackComponent, notFound, phaseOutput, makeContractGenerator } from "@jay-framework/fullstack-component";
5
5
  import fs from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import yaml from "js-yaml";
@@ -331,82 +331,88 @@ async function findContentDirs(projectRoot) {
331
331
  return [];
332
332
  }
333
333
  }
334
- async function* generateDataPagesContract() {
334
+ const generateDataPagesContract = makeContractGenerator().generateWith(async () => {
335
335
  const projectRoot = process.cwd();
336
336
  const dirs = await findContentDirs(projectRoot);
337
- for (const dir of dirs) {
338
- const schema = await loadSchema(dir);
339
- const contractYaml = [
340
- `name: ${schema.name}-data-pages`,
341
- `description: Per-item pages for ${schema.name}`,
342
- "",
343
- "props:",
344
- " - name: contentDir",
345
- " kind: required",
346
- " - name: file",
347
- " kind: required",
348
- "",
349
- "params:",
350
- " - name: slug",
351
- " kind: required",
352
- "",
353
- "tags:",
354
- tagsToYaml(schema.tags, 1)
355
- ].join("\n");
356
- yield { name: schema.name, yaml: contractYaml };
357
- }
358
- }
359
- async function* generateDataListContract() {
337
+ return Promise.all(
338
+ dirs.map(async (dir) => {
339
+ const schema = await loadSchema(dir);
340
+ const yaml2 = [
341
+ `name: ${schema.name}-data-pages`,
342
+ `description: Per-item pages for ${schema.name}`,
343
+ "",
344
+ "props:",
345
+ " - name: contentDir",
346
+ " kind: required",
347
+ " - name: file",
348
+ " kind: required",
349
+ "",
350
+ "params:",
351
+ " - name: slug",
352
+ " kind: required",
353
+ "",
354
+ "tags:",
355
+ tagsToYaml(schema.tags, 1)
356
+ ].join("\n");
357
+ return { name: schema.name, yaml: yaml2 };
358
+ })
359
+ );
360
+ });
361
+ const generateDataListContract = makeContractGenerator().generateWith(async () => {
360
362
  const projectRoot = process.cwd();
361
363
  const dirs = await findContentDirs(projectRoot);
362
- for (const dir of dirs) {
363
- const schema = await loadSchema(dir);
364
- const slugField = schema.slugField;
365
- const contractYaml = [
366
- `name: ${schema.name}-data-list`,
367
- `description: List view for ${schema.name}`,
368
- "",
369
- "props:",
370
- " - name: contentDir",
371
- " kind: required",
372
- " - name: file",
373
- " kind: required",
374
- "",
375
- "tags:",
376
- " - tag: items",
377
- " type: sub-contract",
378
- " repeated: true",
379
- ` trackBy: ${slugField}`,
380
- " phase: slow",
381
- " tags:",
382
- tagsToYaml(schema.tags, 3)
383
- ].join("\n");
384
- yield { name: schema.name, yaml: contractYaml };
385
- }
386
- }
387
- async function* generateDataItemContract() {
364
+ return Promise.all(
365
+ dirs.map(async (dir) => {
366
+ const schema = await loadSchema(dir);
367
+ const slugField = schema.slugField;
368
+ const yaml2 = [
369
+ `name: ${schema.name}-data-list`,
370
+ `description: List view for ${schema.name}`,
371
+ "",
372
+ "props:",
373
+ " - name: contentDir",
374
+ " kind: required",
375
+ " - name: file",
376
+ " kind: required",
377
+ "",
378
+ "tags:",
379
+ " - tag: items",
380
+ " type: sub-contract",
381
+ " repeated: true",
382
+ ` trackBy: ${slugField}`,
383
+ " phase: slow",
384
+ " tags:",
385
+ tagsToYaml(schema.tags, 3)
386
+ ].join("\n");
387
+ return { name: schema.name, yaml: yaml2 };
388
+ })
389
+ );
390
+ });
391
+ const generateDataItemContract = makeContractGenerator().generateWith(async () => {
388
392
  const projectRoot = process.cwd();
389
393
  const dirs = await findContentDirs(projectRoot);
390
- for (const dir of dirs) {
391
- const schema = await loadSchema(dir);
392
- const contractYaml = [
393
- `name: ${schema.name}-data-item`,
394
- `description: Single item view for ${schema.name}`,
395
- "",
396
- "props:",
397
- " - name: contentDir",
398
- " kind: required",
399
- " - name: file",
400
- " kind: required",
401
- " - name: slug",
402
- " kind: required",
403
- "",
404
- "tags:",
405
- tagsToYaml(schema.tags, 1)
406
- ].join("\n");
407
- yield { name: schema.name, yaml: contractYaml };
408
- }
409
- }
394
+ return Promise.all(
395
+ dirs.map(async (dir) => {
396
+ const schema = await loadSchema(dir);
397
+ const yaml2 = [
398
+ `name: ${schema.name}-data-item`,
399
+ `description: Single item view for ${schema.name}`,
400
+ "",
401
+ "props:",
402
+ " - name: contentDir",
403
+ " kind: required",
404
+ " - name: file",
405
+ " kind: required",
406
+ " - name: slug",
407
+ " kind: required",
408
+ "",
409
+ "tags:",
410
+ tagsToYaml(schema.tags, 1)
411
+ ].join("\n");
412
+ return { name: schema.name, yaml: yaml2 };
413
+ })
414
+ );
415
+ });
410
416
  function inferType(value) {
411
417
  if (value === null || value === void 0) return "string";
412
418
  if (typeof value === "number") return "number";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/data-files",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "description": "Data files plugin for Jay Framework — CSV, YAML, JSON, JSONL data sources with list views, item views, and per-item pages",
6
6
  "license": "Apache-2.0",
@@ -27,18 +27,18 @@
27
27
  "test": "vitest run"
28
28
  },
29
29
  "dependencies": {
30
- "@jay-framework/component": "^0.23.1",
31
- "@jay-framework/fullstack-component": "^0.23.1",
32
- "@jay-framework/reactive": "^0.23.1",
33
- "@jay-framework/runtime": "^0.23.1",
34
- "@jay-framework/stack-client-runtime": "^0.23.1",
35
- "@jay-framework/stack-server-runtime": "^0.23.1",
30
+ "@jay-framework/component": "^0.24.0",
31
+ "@jay-framework/fullstack-component": "^0.24.0",
32
+ "@jay-framework/reactive": "^0.24.0",
33
+ "@jay-framework/runtime": "^0.24.0",
34
+ "@jay-framework/stack-client-runtime": "^0.24.0",
35
+ "@jay-framework/stack-server-runtime": "^0.24.0",
36
36
  "js-yaml": "^4.1.0",
37
37
  "papaparse": "^5.4.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@jay-framework/dev-environment": "^0.23.1",
41
- "@jay-framework/jay-stack-cli": "^0.23.1",
40
+ "@jay-framework/dev-environment": "^0.24.0",
41
+ "@jay-framework/jay-stack-cli": "^0.24.0",
42
42
  "@types/js-yaml": "^4.0.9",
43
43
  "@types/node": "^22.15.21",
44
44
  "@types/papaparse": "^5.3.14",