@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 +3 -7
- package/dist/index.js +77 -71
- package/package.json +9 -9
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
334
|
+
const generateDataPagesContract = makeContractGenerator().generateWith(async () => {
|
|
335
335
|
const projectRoot = process.cwd();
|
|
336
336
|
const dirs = await findContentDirs(projectRoot);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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.
|
|
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.
|
|
31
|
-
"@jay-framework/fullstack-component": "^0.
|
|
32
|
-
"@jay-framework/reactive": "^0.
|
|
33
|
-
"@jay-framework/runtime": "^0.
|
|
34
|
-
"@jay-framework/stack-client-runtime": "^0.
|
|
35
|
-
"@jay-framework/stack-server-runtime": "^0.
|
|
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.
|
|
41
|
-
"@jay-framework/jay-stack-cli": "^0.
|
|
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",
|