@formfeed/devkit 0.3.4 → 0.3.6
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 +1 -1
- package/index.cjs +8 -6
- package/index.js +8 -6
- package/package.json +3 -3
- package/types/lib/types/generate.d.cts +15 -0
- package/types/lib/types/generate.d.ts +15 -0
- package/types/lib/types/index.d.cts +3 -9
- package/types/lib/types/index.d.ts +3 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @formfeed/devkit
|
|
2
2
|
|
|
3
|
-
The local half of the [Formfeed](https://formfeed.dev) development kit: template folders, project
|
|
3
|
+
The local half of the [Formfeed](https://formfeed.dev/?utm_source=npm&utm_content=devkit) development kit: template folders, project
|
|
4
4
|
configuration (`formfeed.json`) and offline rendering with the same engine the API uses. The
|
|
5
5
|
[`formfeed` CLI](https://www.npmjs.com/package/formfeed) and
|
|
6
6
|
[`@formfeed/testing`](https://www.npmjs.com/package/@formfeed/testing) are built on it; use it
|
package/index.cjs
CHANGED
|
@@ -1229,11 +1229,18 @@ function emitTypeScript(templates, options = {}) {
|
|
|
1229
1229
|
return lines.join("\n") + "\n";
|
|
1230
1230
|
}
|
|
1231
1231
|
|
|
1232
|
-
// packages/devkit/src/lib/types/
|
|
1232
|
+
// packages/devkit/src/lib/types/generate.ts
|
|
1233
1233
|
var defaultTypesFile = {
|
|
1234
1234
|
ts: "formfeed.d.ts",
|
|
1235
1235
|
python: "formfeed_templates.py"
|
|
1236
1236
|
};
|
|
1237
|
+
function generateTypes(sources, language, options = {}) {
|
|
1238
|
+
const reserved = language === "python" ? ["TypedRenders", "AsyncTypedRenders", "Formfeed", "AsyncFormfeed", "Render", "Any", "Literal", "Union", "Never", "NotRequired", "TypedDict"] : ["FormfeedTemplates"];
|
|
1239
|
+
const model = buildTypes(sources, reserved);
|
|
1240
|
+
return language === "python" ? emitPython(model) : emitTypeScript(model, options);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// packages/devkit/src/lib/types/index.ts
|
|
1237
1244
|
function localTypeSource(tpl) {
|
|
1238
1245
|
if (tpl.dataSchema) return { slug: tpl.slug, schema: tpl.dataSchema, origin: "local" };
|
|
1239
1246
|
const sets = Object.values(tpl.dataSets);
|
|
@@ -1243,11 +1250,6 @@ function localTypeSource(tpl) {
|
|
|
1243
1250
|
origin: "inferred"
|
|
1244
1251
|
};
|
|
1245
1252
|
}
|
|
1246
|
-
function generateTypes(sources, language, options = {}) {
|
|
1247
|
-
const reserved = language === "python" ? ["TypedRenders", "AsyncTypedRenders", "Formfeed", "AsyncFormfeed", "Render", "Any", "Literal", "Union", "Never", "NotRequired", "TypedDict"] : ["FormfeedTemplates"];
|
|
1248
|
-
const model = buildTypes(sources, reserved);
|
|
1249
|
-
return language === "python" ? emitPython(model) : emitTypeScript(model, options);
|
|
1250
|
-
}
|
|
1251
1253
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1252
1254
|
0 && (module.exports = {
|
|
1253
1255
|
DevkitError,
|
package/index.js
CHANGED
|
@@ -1171,11 +1171,18 @@ function emitTypeScript(templates, options = {}) {
|
|
|
1171
1171
|
return lines.join("\n") + "\n";
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
|
-
// packages/devkit/src/lib/types/
|
|
1174
|
+
// packages/devkit/src/lib/types/generate.ts
|
|
1175
1175
|
var defaultTypesFile = {
|
|
1176
1176
|
ts: "formfeed.d.ts",
|
|
1177
1177
|
python: "formfeed_templates.py"
|
|
1178
1178
|
};
|
|
1179
|
+
function generateTypes(sources, language, options = {}) {
|
|
1180
|
+
const reserved = language === "python" ? ["TypedRenders", "AsyncTypedRenders", "Formfeed", "AsyncFormfeed", "Render", "Any", "Literal", "Union", "Never", "NotRequired", "TypedDict"] : ["FormfeedTemplates"];
|
|
1181
|
+
const model = buildTypes(sources, reserved);
|
|
1182
|
+
return language === "python" ? emitPython(model) : emitTypeScript(model, options);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// packages/devkit/src/lib/types/index.ts
|
|
1179
1186
|
function localTypeSource(tpl) {
|
|
1180
1187
|
if (tpl.dataSchema) return { slug: tpl.slug, schema: tpl.dataSchema, origin: "local" };
|
|
1181
1188
|
const sets = Object.values(tpl.dataSets);
|
|
@@ -1185,11 +1192,6 @@ function localTypeSource(tpl) {
|
|
|
1185
1192
|
origin: "inferred"
|
|
1186
1193
|
};
|
|
1187
1194
|
}
|
|
1188
|
-
function generateTypes(sources, language, options = {}) {
|
|
1189
|
-
const reserved = language === "python" ? ["TypedRenders", "AsyncTypedRenders", "Formfeed", "AsyncFormfeed", "Render", "Any", "Literal", "Union", "Never", "NotRequired", "TypedDict"] : ["FormfeedTemplates"];
|
|
1190
|
-
const model = buildTypes(sources, reserved);
|
|
1191
|
-
return language === "python" ? emitPython(model) : emitTypeScript(model, options);
|
|
1192
|
-
}
|
|
1193
1195
|
export {
|
|
1194
1196
|
DevkitError,
|
|
1195
1197
|
brandFromJson,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formfeed/devkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Formfeed template folders, project config and local rendering, shared by the CLI and @formfeed/testing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
],
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@formfeed/engine": "0.3.
|
|
34
|
-
"@formfeed/sdk": "0.3.
|
|
33
|
+
"@formfeed/engine": "0.3.6",
|
|
34
|
+
"@formfeed/sdk": "0.3.6"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"formfeed",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TypeScriptOptions } from './emit-ts.cjs';
|
|
2
|
+
import { type TypeSource } from './model.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* `formfeed types` without the file system (spec 19 §2): a schema in, a generated file out. Apart
|
|
5
|
+
* from `index.ts`, which reads template folders and therefore brings the engine with it, so the
|
|
6
|
+
* landing site's browser tool can emit exactly what the CLI emits. `@formfeed/devkit/emit` in this
|
|
7
|
+
* workspace; the published package exposes the same functions from its single entry.
|
|
8
|
+
*/
|
|
9
|
+
export type TypesLanguage = 'ts' | 'python';
|
|
10
|
+
export declare const defaultTypesFile: Record<TypesLanguage, string>;
|
|
11
|
+
/** The generated file for `sources` in `language`; the same input always gives the same bytes. */
|
|
12
|
+
export declare function generateTypes(sources: TypeSource[], language: TypesLanguage, options?: TypeScriptOptions): string;
|
|
13
|
+
export { buildTypes, pascalCase, relaxRequired, singular } from './model.cjs';
|
|
14
|
+
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeSource } from './model.cjs';
|
|
15
|
+
export type { TypeScriptOptions } from './emit-ts.cjs';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TypeScriptOptions } from './emit-ts.js';
|
|
2
|
+
import { type TypeSource } from './model.js';
|
|
3
|
+
/**
|
|
4
|
+
* `formfeed types` without the file system (spec 19 §2): a schema in, a generated file out. Apart
|
|
5
|
+
* from `index.ts`, which reads template folders and therefore brings the engine with it, so the
|
|
6
|
+
* landing site's browser tool can emit exactly what the CLI emits. `@formfeed/devkit/emit` in this
|
|
7
|
+
* workspace; the published package exposes the same functions from its single entry.
|
|
8
|
+
*/
|
|
9
|
+
export type TypesLanguage = 'ts' | 'python';
|
|
10
|
+
export declare const defaultTypesFile: Record<TypesLanguage, string>;
|
|
11
|
+
/** The generated file for `sources` in `language`; the same input always gives the same bytes. */
|
|
12
|
+
export declare function generateTypes(sources: TypeSource[], language: TypesLanguage, options?: TypeScriptOptions): string;
|
|
13
|
+
export { buildTypes, pascalCase, relaxRequired, singular } from './model.js';
|
|
14
|
+
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeSource } from './model.js';
|
|
15
|
+
export type { TypeScriptOptions } from './emit-ts.js';
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import type { LocalTemplate } from '../project.cjs';
|
|
2
|
-
import {
|
|
3
|
-
import { type TypeSource } from './model.cjs';
|
|
4
|
-
export type TypesLanguage = 'ts' | 'python';
|
|
5
|
-
export declare const defaultTypesFile: Record<TypesLanguage, string>;
|
|
2
|
+
import type { TypeSource } from './model.cjs';
|
|
6
3
|
/**
|
|
7
4
|
* The schema of a template folder: `schema.json` when it has one, else inferred over all its data
|
|
8
5
|
* sets (a field only some sets carry is optional), marked as inferred so every field is optional.
|
|
9
6
|
*/
|
|
10
7
|
export declare function localTypeSource(tpl: LocalTemplate): TypeSource;
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export { buildTypes, pascalCase, relaxRequired, singular } from './model.cjs';
|
|
14
|
-
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeSource } from './model.cjs';
|
|
15
|
-
export type { TypeScriptOptions } from './emit-ts.cjs';
|
|
8
|
+
export { buildTypes, defaultTypesFile, generateTypes, pascalCase, relaxRequired, singular } from './generate.cjs';
|
|
9
|
+
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeScriptOptions, TypeSource, TypesLanguage } from './generate.cjs';
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import type { LocalTemplate } from '../project.js';
|
|
2
|
-
import {
|
|
3
|
-
import { type TypeSource } from './model.js';
|
|
4
|
-
export type TypesLanguage = 'ts' | 'python';
|
|
5
|
-
export declare const defaultTypesFile: Record<TypesLanguage, string>;
|
|
2
|
+
import type { TypeSource } from './model.js';
|
|
6
3
|
/**
|
|
7
4
|
* The schema of a template folder: `schema.json` when it has one, else inferred over all its data
|
|
8
5
|
* sets (a field only some sets carry is optional), marked as inferred so every field is optional.
|
|
9
6
|
*/
|
|
10
7
|
export declare function localTypeSource(tpl: LocalTemplate): TypeSource;
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export { buildTypes, pascalCase, relaxRequired, singular } from './model.js';
|
|
14
|
-
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeSource } from './model.js';
|
|
15
|
-
export type { TypeScriptOptions } from './emit-ts.js';
|
|
8
|
+
export { buildTypes, defaultTypesFile, generateTypes, pascalCase, relaxRequired, singular } from './generate.js';
|
|
9
|
+
export type { SchemaOrigin, TemplateTypes, TypeNode, TypeScriptOptions, TypeSource, TypesLanguage } from './generate.js';
|