@forumulate/cli 0.4.0 → 0.8.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 +116 -5
- package/dist/api/args.d.ts +21 -0
- package/dist/api/args.d.ts.map +1 -0
- package/dist/api/args.js +81 -0
- package/dist/api/args.js.map +1 -0
- package/dist/api/command.d.ts +17 -0
- package/dist/api/command.d.ts.map +1 -0
- package/dist/api/command.js +182 -0
- package/dist/api/command.js.map +1 -0
- package/dist/api/describe.d.ts +5 -0
- package/dist/api/describe.d.ts.map +1 -0
- package/dist/api/describe.js +121 -0
- package/dist/api/describe.js.map +1 -0
- package/dist/api/http.d.ts +81 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +183 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/operations.json +1 -0
- package/dist/api/output.d.ts +35 -0
- package/dist/api/output.d.ts.map +1 -0
- package/dist/api/output.js +176 -0
- package/dist/api/output.js.map +1 -0
- package/dist/api/request.d.ts +37 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +230 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/send.d.ts +35 -0
- package/dist/api/send.d.ts.map +1 -0
- package/dist/api/send.js +85 -0
- package/dist/api/send.js.map +1 -0
- package/dist/api/spec.d.ts +96 -0
- package/dist/api/spec.d.ts.map +1 -0
- package/dist/api/spec.js +126 -0
- package/dist/api/spec.js.map +1 -0
- package/dist/cli.js +12 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/completion.d.ts +12 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +153 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +144 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +35 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +59 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/groups-api.d.ts +11 -0
- package/dist/commands/groups-api.d.ts.map +1 -0
- package/dist/commands/groups-api.js +140 -0
- package/dist/commands/groups-api.js.map +1 -0
- package/dist/commands/groups-community.d.ts +15 -0
- package/dist/commands/groups-community.d.ts.map +1 -0
- package/dist/commands/groups-community.js +344 -0
- package/dist/commands/groups-community.js.map +1 -0
- package/dist/commands/groups-content.d.ts +10 -0
- package/dist/commands/groups-content.d.ts.map +1 -0
- package/dist/commands/groups-content.js +331 -0
- package/dist/commands/groups-content.js.map +1 -0
- package/dist/commands/groups-docs.d.ts +12 -0
- package/dist/commands/groups-docs.d.ts.map +1 -0
- package/dist/commands/groups-docs.js +414 -0
- package/dist/commands/groups-docs.js.map +1 -0
- package/dist/commands/groups-org.d.ts +10 -0
- package/dist/commands/groups-org.d.ts.map +1 -0
- package/dist/commands/groups-org.js +405 -0
- package/dist/commands/groups-org.js.map +1 -0
- package/dist/commands/groups-site.d.ts +3 -0
- package/dist/commands/groups-site.d.ts.map +1 -0
- package/dist/commands/groups-site.js +230 -0
- package/dist/commands/groups-site.js.map +1 -0
- package/dist/commands/groups-spaces.d.ts +3 -0
- package/dist/commands/groups-spaces.d.ts.map +1 -0
- package/dist/commands/groups-spaces.js +273 -0
- package/dist/commands/groups-spaces.js.map +1 -0
- package/dist/commands/groups-types.d.ts +3 -0
- package/dist/commands/groups-types.d.ts.map +1 -0
- package/dist/commands/groups-types.js +251 -0
- package/dist/commands/groups-types.js.map +1 -0
- package/dist/commands/groups.d.ts +4 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +71 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +118 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/resource.d.ts +86 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +314 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/content/command.d.ts +34 -0
- package/dist/content/command.d.ts.map +1 -0
- package/dist/content/command.js +225 -0
- package/dist/content/command.js.map +1 -0
- package/dist/content/library.d.ts +23 -0
- package/dist/content/library.d.ts.map +1 -0
- package/dist/content/library.js +41 -0
- package/dist/content/library.js.map +1 -0
- package/dist/content/render.d.ts +15 -0
- package/dist/content/render.d.ts.map +1 -0
- package/dist/content/render.js +85 -0
- package/dist/content/render.js.map +1 -0
- package/dist/content/types-gen.d.ts +40 -0
- package/dist/content/types-gen.d.ts.map +1 -0
- package/dist/content/types-gen.js +200 -0
- package/dist/content/types-gen.js.map +1 -0
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +142 -0
- package/dist/help.js.map +1 -0
- package/dist/import/coerce.d.ts +34 -0
- package/dist/import/coerce.d.ts.map +1 -0
- package/dist/import/coerce.js +134 -0
- package/dist/import/coerce.js.map +1 -0
- package/dist/import/command.d.ts +25 -0
- package/dist/import/command.d.ts.map +1 -0
- package/dist/import/command.js +127 -0
- package/dist/import/command.js.map +1 -0
- package/dist/import/config.d.ts +39 -0
- package/dist/import/config.d.ts.map +1 -0
- package/dist/import/config.js +48 -0
- package/dist/import/config.js.map +1 -0
- package/dist/import/contentful.d.ts +3 -0
- package/dist/import/contentful.d.ts.map +1 -0
- package/dist/import/contentful.js +179 -0
- package/dist/import/contentful.js.map +1 -0
- package/dist/import/disk.d.ts +4 -0
- package/dist/import/disk.d.ts.map +1 -0
- package/dist/import/disk.js +19 -0
- package/dist/import/disk.js.map +1 -0
- package/dist/import/engine-locales.d.ts +35 -0
- package/dist/import/engine-locales.d.ts.map +1 -0
- package/dist/import/engine-locales.js +61 -0
- package/dist/import/engine-locales.js.map +1 -0
- package/dist/import/engine.d.ts +29 -0
- package/dist/import/engine.d.ts.map +1 -0
- package/dist/import/engine.js +248 -0
- package/dist/import/engine.js.map +1 -0
- package/dist/import/media.d.ts +24 -0
- package/dist/import/media.d.ts.map +1 -0
- package/dist/import/media.js +39 -0
- package/dist/import/media.js.map +1 -0
- package/dist/import/model-fields.d.ts +22 -0
- package/dist/import/model-fields.d.ts.map +1 -0
- package/dist/import/model-fields.js +60 -0
- package/dist/import/model-fields.js.map +1 -0
- package/dist/import/payload/index.d.ts +9 -0
- package/dist/import/payload/index.d.ts.map +1 -0
- package/dist/import/payload/index.js +129 -0
- package/dist/import/payload/index.js.map +1 -0
- package/dist/import/report.d.ts +5 -0
- package/dist/import/report.d.ts.map +1 -0
- package/dist/import/report.js +52 -0
- package/dist/import/report.js.map +1 -0
- package/dist/import/richtext-core.d.ts +26 -0
- package/dist/import/richtext-core.d.ts.map +1 -0
- package/dist/import/richtext-core.js +65 -0
- package/dist/import/richtext-core.js.map +1 -0
- package/dist/import/richtext-html.d.ts +5 -0
- package/dist/import/richtext-html.d.ts.map +1 -0
- package/dist/import/richtext-html.js +311 -0
- package/dist/import/richtext-html.js.map +1 -0
- package/dist/import/richtext-json.d.ts +10 -0
- package/dist/import/richtext-json.d.ts.map +1 -0
- package/dist/import/richtext-json.js +250 -0
- package/dist/import/richtext-json.js.map +1 -0
- package/dist/import/sanity.d.ts +8 -0
- package/dist/import/sanity.d.ts.map +1 -0
- package/dist/import/sanity.js +158 -0
- package/dist/import/sanity.js.map +1 -0
- package/dist/import/strapi-archive.d.ts +6 -0
- package/dist/import/strapi-archive.d.ts.map +1 -0
- package/dist/import/strapi-archive.js +127 -0
- package/dist/import/strapi-archive.js.map +1 -0
- package/dist/import/strapi.d.ts +7 -0
- package/dist/import/strapi.d.ts.map +1 -0
- package/dist/import/strapi.js +185 -0
- package/dist/import/strapi.js.map +1 -0
- package/dist/import/tar.d.ts +3 -0
- package/dist/import/tar.d.ts.map +1 -0
- package/dist/import/tar.js +48 -0
- package/dist/import/tar.js.map +1 -0
- package/dist/import/types.d.ts +157 -0
- package/dist/import/types.d.ts.map +1 -0
- package/dist/import/types.js +12 -0
- package/dist/import/types.js.map +1 -0
- package/dist/import/wordpress.d.ts +15 -0
- package/dist/import/wordpress.d.ts.map +1 -0
- package/dist/import/wordpress.js +147 -0
- package/dist/import/wordpress.js.map +1 -0
- package/dist/publish/scan.d.ts +1 -1
- package/dist/publish/scan.d.ts.map +1 -1
- package/dist/publish/scan.js +2 -2
- package/dist/publish/scan.js.map +1 -1
- package/dist/publish-dir.d.ts +54 -0
- package/dist/publish-dir.d.ts.map +1 -0
- package/dist/publish-dir.js +119 -0
- package/dist/publish-dir.js.map +1 -0
- package/dist/run.d.ts +21 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +70 -65
- package/dist/run.js.map +1 -1
- package/dist/translations/command.d.ts +36 -0
- package/dist/translations/command.d.ts.map +1 -0
- package/dist/translations/command.js +411 -0
- package/dist/translations/command.js.map +1 -0
- package/dist/translations/extras.d.ts +29 -0
- package/dist/translations/extras.d.ts.map +1 -0
- package/dist/translations/extras.js +123 -0
- package/dist/translations/extras.js.map +1 -0
- package/dist/translations/files.d.ts +22 -0
- package/dist/translations/files.d.ts.map +1 -0
- package/dist/translations/files.js +75 -0
- package/dist/translations/files.js.map +1 -0
- package/dist/translations/sync.d.ts +89 -0
- package/dist/translations/sync.d.ts.map +1 -0
- package/dist/translations/sync.js +215 -0
- package/dist/translations/sync.js.map +1 -0
- package/dist/translations/target.d.ts +33 -0
- package/dist/translations/target.d.ts.map +1 -0
- package/dist/translations/target.js +54 -0
- package/dist/translations/target.js.map +1 -0
- package/dist/translations/xliff.d.ts +29 -0
- package/dist/translations/xliff.d.ts.map +1 -0
- package/dist/translations/xliff.js +62 -0
- package/dist/translations/xliff.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript from a content library's `schema.json` (plan P4-T1, spec 7):
|
|
4
|
+
* `forumulate content types --library acme-site --out src/forumulate.d.ts`.
|
|
5
|
+
*
|
|
6
|
+
* The schema names everything already: `type.<key>` is a content type's
|
|
7
|
+
* `fields`, `entry.<key>` the delivery envelope around them (marked
|
|
8
|
+
* `x-forumulate-global` for a global), `block.<key>` a block type, and
|
|
9
|
+
* `json.*` the hoisted definitions of a json field's own schema. Each becomes
|
|
10
|
+
* one named type, so a `json` field is typed from its schema, a blocks
|
|
11
|
+
* field is a union discriminated on `blockType`, and a reference to an
|
|
12
|
+
* author is an `AuthorFields`.
|
|
13
|
+
*
|
|
14
|
+
* One deliberate departure from the schema: objects are CLOSED here. The
|
|
15
|
+
* schema says `additionalProperties: true` so a site keeps working while a
|
|
16
|
+
* field is being renamed; the types say exactly what the model has, so code
|
|
17
|
+
* that still reads the old name fails to compile after the model changes.
|
|
18
|
+
* That compile error is the point of generating types at all.
|
|
19
|
+
*
|
|
20
|
+
* Pure and deterministic: same schema, same bytes.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.pascal = pascal;
|
|
24
|
+
exports.defName = defName;
|
|
25
|
+
exports.toType = toType;
|
|
26
|
+
exports.generateTypes = generateTypes;
|
|
27
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
28
|
+
const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
29
|
+
function pascal(s) {
|
|
30
|
+
const out = s
|
|
31
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
32
|
+
.split(/[^A-Za-z0-9]+/)
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.map((w) => w[0].toUpperCase() + w.slice(1))
|
|
35
|
+
.join('');
|
|
36
|
+
return /^[0-9]/.test(out) ? `T${out}` : out || 'T';
|
|
37
|
+
}
|
|
38
|
+
/** The TypeScript name of a `$defs` entry. */
|
|
39
|
+
function defName(def) {
|
|
40
|
+
const dot = def.indexOf('.');
|
|
41
|
+
const kind = def.slice(0, dot);
|
|
42
|
+
const rest = def.slice(dot + 1);
|
|
43
|
+
if (kind === 'type')
|
|
44
|
+
return `${pascal(rest)}Fields`;
|
|
45
|
+
if (kind === 'entry')
|
|
46
|
+
return `${pascal(rest)}Entry`;
|
|
47
|
+
if (kind === 'block')
|
|
48
|
+
return `${pascal(rest)}Block`;
|
|
49
|
+
return `Json${pascal(rest.replace(/~/g, ' '))}`;
|
|
50
|
+
}
|
|
51
|
+
const literal = (v) => JSON.stringify(v);
|
|
52
|
+
const key = (k) => (IDENT.test(k) ? k : JSON.stringify(k));
|
|
53
|
+
/** Parenthesised when a union or intersection sits at its top level (`(A | B)[]`). */
|
|
54
|
+
function paren(t) {
|
|
55
|
+
let depth = 0;
|
|
56
|
+
for (let i = 0; i < t.length; i++) {
|
|
57
|
+
const c = t[i];
|
|
58
|
+
if (c === '{' || c === '(' || c === '[' || c === '<')
|
|
59
|
+
depth++;
|
|
60
|
+
else if (c === '}' || c === ')' || c === ']' || c === '>')
|
|
61
|
+
depth--;
|
|
62
|
+
else if (c === '"') {
|
|
63
|
+
// Skip a string literal, escapes included: an enum value may hold a `|`.
|
|
64
|
+
for (i++; i < t.length && t[i] !== '"'; i++)
|
|
65
|
+
if (t[i] === '\\')
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
else if (depth === 0 && (c === '|' || c === '&'))
|
|
69
|
+
return `(${t})`;
|
|
70
|
+
}
|
|
71
|
+
return t;
|
|
72
|
+
}
|
|
73
|
+
function comment(s, indent) {
|
|
74
|
+
const text = [s.title, s.description].filter((x) => typeof x === 'string' && x.length > 0);
|
|
75
|
+
const uniq = [...new Set(text)];
|
|
76
|
+
if (!uniq.length)
|
|
77
|
+
return '';
|
|
78
|
+
return `${indent}/** ${uniq.join(' — ').replace(/\*\//g, '*\\/').replace(/\n/g, ' ')} */\n`;
|
|
79
|
+
}
|
|
80
|
+
/** One schema as a TypeScript type expression. */
|
|
81
|
+
function toType(s, indent = '') {
|
|
82
|
+
if (s === true || s === undefined)
|
|
83
|
+
return 'unknown';
|
|
84
|
+
if (s === false)
|
|
85
|
+
return 'never';
|
|
86
|
+
if (!isObj(s))
|
|
87
|
+
return 'unknown';
|
|
88
|
+
if (typeof s.$ref === 'string') {
|
|
89
|
+
const m = /^#\/\$defs\/(.+)$/.exec(s.$ref);
|
|
90
|
+
return m ? defName(m[1]) : 'unknown';
|
|
91
|
+
}
|
|
92
|
+
if ('const' in s)
|
|
93
|
+
return literal(s.const);
|
|
94
|
+
if (Array.isArray(s.enum))
|
|
95
|
+
return s.enum.length ? s.enum.map(literal).join(' | ') : 'never';
|
|
96
|
+
for (const k of ['oneOf', 'anyOf']) {
|
|
97
|
+
if (Array.isArray(s[k])) {
|
|
98
|
+
const parts = [...new Set(s[k].map((x) => toType(x, indent)))];
|
|
99
|
+
return parts.length ? parts.join(' | ') : 'never';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(s.allOf))
|
|
103
|
+
return s.allOf.map((x) => paren(toType(x, indent))).join(' & ');
|
|
104
|
+
const types = Array.isArray(s.type) ? s.type : typeof s.type === 'string' ? [s.type] : [];
|
|
105
|
+
if (!types.length) {
|
|
106
|
+
if (isObj(s.properties) || s.additionalProperties !== undefined)
|
|
107
|
+
return objectType(s, indent);
|
|
108
|
+
if (s.items !== undefined)
|
|
109
|
+
return arrayType(s, indent);
|
|
110
|
+
return 'unknown';
|
|
111
|
+
}
|
|
112
|
+
const parts = types.map((t) => {
|
|
113
|
+
switch (t) {
|
|
114
|
+
case 'string':
|
|
115
|
+
return 'string';
|
|
116
|
+
case 'number':
|
|
117
|
+
case 'integer':
|
|
118
|
+
return 'number';
|
|
119
|
+
case 'boolean':
|
|
120
|
+
return 'boolean';
|
|
121
|
+
case 'null':
|
|
122
|
+
return 'null';
|
|
123
|
+
case 'array':
|
|
124
|
+
return arrayType(s, indent);
|
|
125
|
+
case 'object':
|
|
126
|
+
return objectType(s, indent);
|
|
127
|
+
default:
|
|
128
|
+
return 'unknown';
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return [...new Set(parts)].join(' | ');
|
|
132
|
+
}
|
|
133
|
+
function arrayType(s, indent) {
|
|
134
|
+
if (Array.isArray(s.items))
|
|
135
|
+
return `[${s.items.map((x) => toType(x, indent)).join(', ')}]`;
|
|
136
|
+
return `${paren(toType(s.items, indent))}[]`;
|
|
137
|
+
}
|
|
138
|
+
function objectType(s, indent) {
|
|
139
|
+
const props = isObj(s.properties) ? s.properties : {};
|
|
140
|
+
const names = Object.keys(props);
|
|
141
|
+
if (!names.length) {
|
|
142
|
+
// A map: its values are typed when the schema says how.
|
|
143
|
+
return isObj(s.additionalProperties) ? `Record<string, ${toType(s.additionalProperties, indent)}>` : 'Record<string, unknown>';
|
|
144
|
+
}
|
|
145
|
+
return `{\n${members(s, indent + ' ')}${indent}}`;
|
|
146
|
+
}
|
|
147
|
+
function members(s, indent) {
|
|
148
|
+
const props = (isObj(s.properties) ? s.properties : {});
|
|
149
|
+
const required = new Set(Array.isArray(s.required) ? s.required : []);
|
|
150
|
+
let out = '';
|
|
151
|
+
for (const [name, prop] of Object.entries(props)) {
|
|
152
|
+
out += isObj(prop) ? comment(prop, indent) : '';
|
|
153
|
+
out += `${indent}${key(name)}${required.has(name) ? '' : '?'}: ${toType(prop, indent)};\n`;
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A `$defs` entry as a declaration. Always a type alias, never an interface:
|
|
159
|
+
* an interface is not assignable to `Record<string, unknown>` (it has no
|
|
160
|
+
* implicit index signature), and that is the constraint every generic
|
|
161
|
+
* content helper puts on `fields` (`Entry<T = Record<string, unknown>>`).
|
|
162
|
+
*/
|
|
163
|
+
function declaration(def, s) {
|
|
164
|
+
const doc = isObj(s) ? comment(s, '') : '';
|
|
165
|
+
return `${doc}export type ${defName(def)} = ${toType(s)};\n`;
|
|
166
|
+
}
|
|
167
|
+
/** The whole `forumulate.d.ts` for a library schema. */
|
|
168
|
+
function generateTypes(schema, opts = {}) {
|
|
169
|
+
if (!isObj(schema) || !isObj(schema.$defs))
|
|
170
|
+
throw new Error('This is not a content library schema: it has no `$defs`.');
|
|
171
|
+
const defs = schema.$defs;
|
|
172
|
+
const entries = Object.keys(defs).filter((d) => d.startsWith('entry.'));
|
|
173
|
+
const isGlobal = (k) => isObj(defs[`entry.${k}`]) && defs[`entry.${k}`]['x-forumulate-global'] === true;
|
|
174
|
+
const typeKeys = Object.keys(defs).filter((d) => d.startsWith('type.')).map((d) => d.slice(5));
|
|
175
|
+
const blockKeys = Object.keys(defs).filter((d) => d.startsWith('block.')).map((d) => d.slice(6));
|
|
176
|
+
const collections = typeKeys.filter((k) => !isGlobal(k));
|
|
177
|
+
const globals = typeKeys.filter((k) => isGlobal(k));
|
|
178
|
+
const parts = [
|
|
179
|
+
'/* eslint-disable */',
|
|
180
|
+
'// Generated by `forumulate content types`. Do not edit: regenerate after a model change',
|
|
181
|
+
`// (${opts.command ?? 'forumulate content types --library <id> --out <file>'}).`,
|
|
182
|
+
...(opts.libraryId ? [`// Content library: ${opts.libraryId}`] : []),
|
|
183
|
+
'// Fields are optional because an entry may leave them empty; objects are closed so a',
|
|
184
|
+
'// field removed or renamed in the model is a compile error wherever code still reads it.',
|
|
185
|
+
'',
|
|
186
|
+
];
|
|
187
|
+
// Fields, then entries, then blocks, then json schemas: the order a reader looks for them.
|
|
188
|
+
const order = ['type.', 'entry.', 'block.', 'json.'];
|
|
189
|
+
const sorted = Object.keys(defs).sort((a, b) => {
|
|
190
|
+
const ra = order.findIndex((p) => a.startsWith(p));
|
|
191
|
+
const rb = order.findIndex((p) => b.startsWith(p));
|
|
192
|
+
return (ra < 0 ? 9 : ra) - (rb < 0 ? 9 : rb);
|
|
193
|
+
});
|
|
194
|
+
for (const def of sorted)
|
|
195
|
+
parts.push(declaration(def, defs[def]));
|
|
196
|
+
const map = (name, keys, suffix, doc) => `/** ${doc} */\nexport type ${name} = {\n${keys.map((k) => ` ${key(k)}: ${suffix(k)};\n`).join('')}};\n`;
|
|
197
|
+
parts.push(`/** Every block type, discriminated on \`blockType\`. */\nexport type Block = ${blockKeys.length ? blockKeys.map((k) => defName(`block.${k}`)).join(' | ') : 'never'};\n`, "export type BlockTypeKey = Block['blockType'];\n", map('Blocks', blockKeys, (k) => defName(`block.${k}`), 'Block types by key.'), map('ContentTypes', collections, (k) => defName(`type.${k}`), 'The fields of each collection (a content type with many entries), by key.'), map('Globals', globals, (k) => defName(`type.${k}`), 'The fields of each global (one entry per locale), by key.'), map('Entries', entries.map((d) => d.slice(6)), (k) => defName(`entry.${k}`), 'The delivery envelope of each content type, by key.'), 'export type ContentTypeKey = keyof ContentTypes;\n', 'export type GlobalKey = keyof Globals;\n', '/** Everything at once, for a client typed against this library. */\nexport type ForumulateContent = {\n types: ContentTypes;\n globals: Globals;\n blocks: Blocks;\n entries: Entries;\n};\n');
|
|
198
|
+
return { source: parts.join('\n'), types: collections, globals, blocks: blockKeys };
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=types-gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-gen.js","sourceRoot":"","sources":["../../src/content/types-gen.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAOH,wBAQC;AAGD,0BAQC;AA2BD,wBA2CC;AAsDD,sCA0CC;AA5LD,MAAM,KAAK,GAAG,CAAC,CAAU,EAAa,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClG,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAE3C,SAAgB,MAAM,CAAC,CAAS;IAC9B,MAAM,GAAG,GAAG,CAAC;SACV,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,KAAK,CAAC,eAAe,CAAC;SACtB,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,G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pD,0CAA0C,EAC1C,mMAAmM,CACpM,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACtF,CAAC"}
|
package/dist/help.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** `forumulate help`. The resource groups print their own (`forumulate spaces --help`). */
|
|
2
|
+
export declare const HELP = "forumulate \u2014 Forumulate command-line interface\n\nUsage:\n forumulate <command> [args]\n\nCommands:\n login [--token <pat>] Store a token for this API, so every other\n command stops needing FORUMULATE_TOKEN in\n the environment\n logout Forget the stored token\n whoami Show the authenticated user\n config set|get|unset|list Defaults: org, space, library, api-version\n (`forumulate config set org acme`)\n\nEvery API operation:\n api list [--tag t] [--search w] Discover operations and their summaries\n api describe <operationId> Parameters and body schema, as flags\n api <operationId> [args] [flags] Call it: --<param> value, --data @f.json,\n api <METHOD> <path> [flags] --field a.b=v, --paginate, --json\n\nResources (each: <group> --help lists its verbs and the operation each calls):\n Org: orgs | members | invites | groups | roles | service-accounts (bots)\n tokens (pats) | webhooks | extensions | audit\n Spaces: spaces | snapshots | shape | domains | assets | space-types (types)\n Docs: items (pages) | docs | collections | versions | change-requests (crs)\n openapi | sdks | github (git)\n Content: blog | forum | changelog | roadmap | status | events | course\n careers | forms (blog/forum/changelog/status: translations \u2026)\n CMS: libraries | entries | media | releases | environments (envs)\n Site: theme | sites | reader\n search <query...> [--org] e.g. spaces create Docs --slug docs --type DOCS\n items create --space docs --file a.md --publish\n docs schedule set <pageId> <when> --space docs\n webhooks deliveries <id>; webhooks replay <id> <d>\n --out <file> where a file answer goes (SDK archive, PDF, CSV export)\n completion bash|zsh|fish Shell completion script\n\nOlder forms, unchanged:\n orgs List your organizations\n spaces <orgId> List spaces in an org\n items <orgId> <spaceId> List what is in a space, with where each\n piece's content lives\n search <orgId> <query...> Unified search across docs/forum/blog\n publish <folder> Publish a folder of Markdown: one folder per\n collection, front matter, assets, order,\n and a forumulate.yaml manifest for space,\n site, theme, OpenAPI and monitors. Re-runs\n change only what changed, then read back.\n --org <id|slug> --space <id|slug> (or org:/space: in the manifest)\n --dry-run print the plan, write nothing (no token needed for a\n public space)\n --prune remove pages/posts/collections with no file (to the trash)\n --only a,b just these slugs, files, folders, or manifest parts\n (site, theme, settings, openapi, monitors)\n --force re-send every page even if it looks unchanged\n --no-verify skip the read-back --pace <ms> gap between writes\n --manifest <file> a manifest somewhere else\n publish <orgId> <spaceId> <pageId> Publish a page\n publish <orgId> <spaceId> <dir> The folder form, with org and space given\n domains <orgId> <spaceId> List this space's domains and their state\n domains verify <orgId> <spaceId> <hostname>\n Re-run verification and say what is missing\n snapshot <orgId> <spaceId> <label> Create a space version snapshot\n content types --library <id|slug> TypeScript for a content library's model:\n collections, globals, the block union\n [--org <id|slug>] [--out forumulate.d.ts] [--preview] [--schema <file>]\n [--check] fail (exit 1) when the file is out of date, write nothing\n content pull --library <id|slug> Write the model to forumulate.content.json\n [--format json|payload] [--out <file>] (payload: forumulate.payload.ts)\n content push [file] Show the diff against the library, then\n apply it as a new model version\n [--library \u2026] [--dry-run] [--yes] [--force]\n [--rename type.field=new | block:hero.field=new | library:field=new]\n [--rename-type old=new] [--rename-block old=new]\n import <payload|contentful|sanity|strapi|wordpress> <export path>\n Bring another CMS's content into a library:\n model, media, entries, references (always\n shows a dry run first)\n Re-running updates entries a\n previous import made. strapi takes a\n folder or an unencrypted export .tar.gz\n --library <id|slug> [--org \u2026] [--dry-run] [--yes]\n [--config payload.config.ts] (payload) the config that becomes the model\n [--publish source|all|none] what to publish (default: what was live)\n [--allow-model-removals] [--pace <ms>] [--base-url <url>] (strapi uploads)\n translations (alias i18n) Every translation capability, one vocabulary\n locales list|add|relabel|remove|set a space's (--space) or library's\n (--library) languages; set es=Espa\u00F1ol fr [--prune] is exact\n status each piece \u00D7 language: missing/draft/published/outdated\n [--locale es,fr] [--fail-on missing,outdated] (exit 1)\n pull one Markdown file per piece per language \u2192 [--out translations]\n [--locale \u2026] [--only slug,\u2026] [--include-missing] (stubs)\n push [dir] diff the files against the API, write what changed [--dry-run]\n auto machine-translate with YOUR DeepL/AI key --locale es\n [--state missing,outdated] [--only \u2026] [--force] [--publish]\n [--library \u2026 --entry id,\u2026] [--dry-run]\n labels pull|push [file] chrome words (--site <id> | --space \u2026)\n overrides pull|push [file] org UI string overrides [--prune]\n [--format json|xliff] for labels and overrides\n item-locale <itemId> <locale|none> correct a piece's declared language\n remove <pieceId> <locale> one translation (--yes)\n entry <entryId> <locale> a library entry's twin [--fields f.json]\n name <locale> <name\u2026> a space's (or --collection's) name\n switcher get|set <f.json> the org's reader language switcher\n provider status|connect|disconnect your DeepL key (DEEPL_API_KEY)\n conformance <collectionUrl> Run the Content Sync Protocol suite against\n any platform's collection endpoint\n doctor <readerUrl> Check a live site from the outside: health,\n public read, canonical, cache headers,\n crawler access, feeds, HTML rewriting\n help Show this help\n\nEnvironment:\n FORUMULATE_TOKEN Personal Access Token (Bearer). Overrides a stored one, so\n CI keeps working exactly as it did. Mint one at\n https://forumulate.com/account/tokens\n FORUMULATE_URL The site (default https://forumulate.com); the API is its\n /api, i.e. https://forumulate.com/api. A value already\n ending in /api is used as-is.\n FORUMULATE_API_URL Exact API base, for a local API with no /api prefix\n (http://localhost:4000). Wins over FORUMULATE_URL.\n FORUMULATE_ORG, FORUMULATE_SPACE, FORUMULATE_LIBRARY\n Defaults for --org, --space and --library; they beat\n `forumulate config set`, a flag beats both.\n FORUMULATE_API_VERSION\n Forumulate-Version for api/resource commands\n (default 2026-12-01).\n\nThe SDK (ForumulateClient.fromEnv) and the MCP server (@forumulate/mcp) read\nthe same variables. Guide: https://forumulate.com/guides/api-tokens-and-scopes\n\nFlags:\n --json Emit raw JSON instead of a formatted summary\n --dry-run (api, resources) print the request instead of sending it\n --dry-run Plan the work and write nothing (publish of a directory)\n --version Print the CLI version\n";
|
|
3
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,eAAO,MAAM,IAAI,ipRAwIhB,CAAC"}
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HELP = void 0;
|
|
4
|
+
/** `forumulate help`. The resource groups print their own (`forumulate spaces --help`). */
|
|
5
|
+
exports.HELP = `forumulate — Forumulate command-line interface
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
forumulate <command> [args]
|
|
9
|
+
|
|
10
|
+
Commands:
|
|
11
|
+
login [--token <pat>] Store a token for this API, so every other
|
|
12
|
+
command stops needing FORUMULATE_TOKEN in
|
|
13
|
+
the environment
|
|
14
|
+
logout Forget the stored token
|
|
15
|
+
whoami Show the authenticated user
|
|
16
|
+
config set|get|unset|list Defaults: org, space, library, api-version
|
|
17
|
+
(\`forumulate config set org acme\`)
|
|
18
|
+
|
|
19
|
+
Every API operation:
|
|
20
|
+
api list [--tag t] [--search w] Discover operations and their summaries
|
|
21
|
+
api describe <operationId> Parameters and body schema, as flags
|
|
22
|
+
api <operationId> [args] [flags] Call it: --<param> value, --data @f.json,
|
|
23
|
+
api <METHOD> <path> [flags] --field a.b=v, --paginate, --json
|
|
24
|
+
|
|
25
|
+
Resources (each: <group> --help lists its verbs and the operation each calls):
|
|
26
|
+
Org: orgs | members | invites | groups | roles | service-accounts (bots)
|
|
27
|
+
tokens (pats) | webhooks | extensions | audit
|
|
28
|
+
Spaces: spaces | snapshots | shape | domains | assets | space-types (types)
|
|
29
|
+
Docs: items (pages) | docs | collections | versions | change-requests (crs)
|
|
30
|
+
openapi | sdks | github (git)
|
|
31
|
+
Content: blog | forum | changelog | roadmap | status | events | course
|
|
32
|
+
careers | forms (blog/forum/changelog/status: translations …)
|
|
33
|
+
CMS: libraries | entries | media | releases | environments (envs)
|
|
34
|
+
Site: theme | sites | reader
|
|
35
|
+
search <query...> [--org] e.g. spaces create Docs --slug docs --type DOCS
|
|
36
|
+
items create --space docs --file a.md --publish
|
|
37
|
+
docs schedule set <pageId> <when> --space docs
|
|
38
|
+
webhooks deliveries <id>; webhooks replay <id> <d>
|
|
39
|
+
--out <file> where a file answer goes (SDK archive, PDF, CSV export)
|
|
40
|
+
completion bash|zsh|fish Shell completion script
|
|
41
|
+
|
|
42
|
+
Older forms, unchanged:
|
|
43
|
+
orgs List your organizations
|
|
44
|
+
spaces <orgId> List spaces in an org
|
|
45
|
+
items <orgId> <spaceId> List what is in a space, with where each
|
|
46
|
+
piece's content lives
|
|
47
|
+
search <orgId> <query...> Unified search across docs/forum/blog
|
|
48
|
+
publish <folder> Publish a folder of Markdown: one folder per
|
|
49
|
+
collection, front matter, assets, order,
|
|
50
|
+
and a forumulate.yaml manifest for space,
|
|
51
|
+
site, theme, OpenAPI and monitors. Re-runs
|
|
52
|
+
change only what changed, then read back.
|
|
53
|
+
--org <id|slug> --space <id|slug> (or org:/space: in the manifest)
|
|
54
|
+
--dry-run print the plan, write nothing (no token needed for a
|
|
55
|
+
public space)
|
|
56
|
+
--prune remove pages/posts/collections with no file (to the trash)
|
|
57
|
+
--only a,b just these slugs, files, folders, or manifest parts
|
|
58
|
+
(site, theme, settings, openapi, monitors)
|
|
59
|
+
--force re-send every page even if it looks unchanged
|
|
60
|
+
--no-verify skip the read-back --pace <ms> gap between writes
|
|
61
|
+
--manifest <file> a manifest somewhere else
|
|
62
|
+
publish <orgId> <spaceId> <pageId> Publish a page
|
|
63
|
+
publish <orgId> <spaceId> <dir> The folder form, with org and space given
|
|
64
|
+
domains <orgId> <spaceId> List this space's domains and their state
|
|
65
|
+
domains verify <orgId> <spaceId> <hostname>
|
|
66
|
+
Re-run verification and say what is missing
|
|
67
|
+
snapshot <orgId> <spaceId> <label> Create a space version snapshot
|
|
68
|
+
content types --library <id|slug> TypeScript for a content library's model:
|
|
69
|
+
collections, globals, the block union
|
|
70
|
+
[--org <id|slug>] [--out forumulate.d.ts] [--preview] [--schema <file>]
|
|
71
|
+
[--check] fail (exit 1) when the file is out of date, write nothing
|
|
72
|
+
content pull --library <id|slug> Write the model to forumulate.content.json
|
|
73
|
+
[--format json|payload] [--out <file>] (payload: forumulate.payload.ts)
|
|
74
|
+
content push [file] Show the diff against the library, then
|
|
75
|
+
apply it as a new model version
|
|
76
|
+
[--library …] [--dry-run] [--yes] [--force]
|
|
77
|
+
[--rename type.field=new | block:hero.field=new | library:field=new]
|
|
78
|
+
[--rename-type old=new] [--rename-block old=new]
|
|
79
|
+
import <payload|contentful|sanity|strapi|wordpress> <export path>
|
|
80
|
+
Bring another CMS's content into a library:
|
|
81
|
+
model, media, entries, references (always
|
|
82
|
+
shows a dry run first)
|
|
83
|
+
Re-running updates entries a
|
|
84
|
+
previous import made. strapi takes a
|
|
85
|
+
folder or an unencrypted export .tar.gz
|
|
86
|
+
--library <id|slug> [--org …] [--dry-run] [--yes]
|
|
87
|
+
[--config payload.config.ts] (payload) the config that becomes the model
|
|
88
|
+
[--publish source|all|none] what to publish (default: what was live)
|
|
89
|
+
[--allow-model-removals] [--pace <ms>] [--base-url <url>] (strapi uploads)
|
|
90
|
+
translations (alias i18n) Every translation capability, one vocabulary
|
|
91
|
+
locales list|add|relabel|remove|set a space's (--space) or library's
|
|
92
|
+
(--library) languages; set es=Español fr [--prune] is exact
|
|
93
|
+
status each piece × language: missing/draft/published/outdated
|
|
94
|
+
[--locale es,fr] [--fail-on missing,outdated] (exit 1)
|
|
95
|
+
pull one Markdown file per piece per language → [--out translations]
|
|
96
|
+
[--locale …] [--only slug,…] [--include-missing] (stubs)
|
|
97
|
+
push [dir] diff the files against the API, write what changed [--dry-run]
|
|
98
|
+
auto machine-translate with YOUR DeepL/AI key --locale es
|
|
99
|
+
[--state missing,outdated] [--only …] [--force] [--publish]
|
|
100
|
+
[--library … --entry id,…] [--dry-run]
|
|
101
|
+
labels pull|push [file] chrome words (--site <id> | --space …)
|
|
102
|
+
overrides pull|push [file] org UI string overrides [--prune]
|
|
103
|
+
[--format json|xliff] for labels and overrides
|
|
104
|
+
item-locale <itemId> <locale|none> correct a piece's declared language
|
|
105
|
+
remove <pieceId> <locale> one translation (--yes)
|
|
106
|
+
entry <entryId> <locale> a library entry's twin [--fields f.json]
|
|
107
|
+
name <locale> <name…> a space's (or --collection's) name
|
|
108
|
+
switcher get|set <f.json> the org's reader language switcher
|
|
109
|
+
provider status|connect|disconnect your DeepL key (DEEPL_API_KEY)
|
|
110
|
+
conformance <collectionUrl> Run the Content Sync Protocol suite against
|
|
111
|
+
any platform's collection endpoint
|
|
112
|
+
doctor <readerUrl> Check a live site from the outside: health,
|
|
113
|
+
public read, canonical, cache headers,
|
|
114
|
+
crawler access, feeds, HTML rewriting
|
|
115
|
+
help Show this help
|
|
116
|
+
|
|
117
|
+
Environment:
|
|
118
|
+
FORUMULATE_TOKEN Personal Access Token (Bearer). Overrides a stored one, so
|
|
119
|
+
CI keeps working exactly as it did. Mint one at
|
|
120
|
+
https://forumulate.com/account/tokens
|
|
121
|
+
FORUMULATE_URL The site (default https://forumulate.com); the API is its
|
|
122
|
+
/api, i.e. https://forumulate.com/api. A value already
|
|
123
|
+
ending in /api is used as-is.
|
|
124
|
+
FORUMULATE_API_URL Exact API base, for a local API with no /api prefix
|
|
125
|
+
(http://localhost:4000). Wins over FORUMULATE_URL.
|
|
126
|
+
FORUMULATE_ORG, FORUMULATE_SPACE, FORUMULATE_LIBRARY
|
|
127
|
+
Defaults for --org, --space and --library; they beat
|
|
128
|
+
\`forumulate config set\`, a flag beats both.
|
|
129
|
+
FORUMULATE_API_VERSION
|
|
130
|
+
Forumulate-Version for api/resource commands
|
|
131
|
+
(default 2026-12-01).
|
|
132
|
+
|
|
133
|
+
The SDK (ForumulateClient.fromEnv) and the MCP server (@forumulate/mcp) read
|
|
134
|
+
the same variables. Guide: https://forumulate.com/guides/api-tokens-and-scopes
|
|
135
|
+
|
|
136
|
+
Flags:
|
|
137
|
+
--json Emit raw JSON instead of a formatted summary
|
|
138
|
+
--dry-run (api, resources) print the request instead of sending it
|
|
139
|
+
--dry-run Plan the work and write nothing (publish of a directory)
|
|
140
|
+
--version Print the CLI version
|
|
141
|
+
`;
|
|
142
|
+
//# sourceMappingURL=help.js.map
|
package/dist/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC9E,QAAA,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwInB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A record's source values as the values of the model's declared fields.
|
|
3
|
+
*
|
|
4
|
+
* Driven by the field's declared TYPE, never by guessing from the value: a
|
|
5
|
+
* number is an id only where the field is a reference. What a value means
|
|
6
|
+
* (a rich-text document, a file, a pointer) is the importer's to say
|
|
7
|
+
* (`ImportSource`); what the library wants it to look like is decided here, so
|
|
8
|
+
* five platforms produce one shape. Anything that cannot be converted is
|
|
9
|
+
* left out and counted, never stored wrong.
|
|
10
|
+
*/
|
|
11
|
+
import type { FieldDecl, ImageResolver, ImportSource, RefTarget } from './types';
|
|
12
|
+
type Obj = Record<string, unknown>;
|
|
13
|
+
export interface CoerceCtx {
|
|
14
|
+
source: ImportSource;
|
|
15
|
+
image: ImageResolver;
|
|
16
|
+
/** The library asset id for a source file, uploading it first if needed. */
|
|
17
|
+
asset(sourceId: string): {
|
|
18
|
+
id: string;
|
|
19
|
+
filename: string;
|
|
20
|
+
} | null;
|
|
21
|
+
/** The entry id for a source record, or null while it does not exist yet / is not in the export. */
|
|
22
|
+
entry(target: RefTarget): string | null;
|
|
23
|
+
blocks: Map<string, FieldDecl[]>;
|
|
24
|
+
/** `type.field` → values that fitted no declared field or could not be converted. */
|
|
25
|
+
dropped: Map<string, number>;
|
|
26
|
+
/** Set when a reference could not be resolved yet; the engine writes the field again once all entries exist. */
|
|
27
|
+
pendingRef: {
|
|
28
|
+
value: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare function coerceFields(fields: FieldDecl[], raw: Obj, ctx: CoerceCtx, path: string, skip?: ReadonlySet<string>): Obj;
|
|
32
|
+
export declare function coerceValue(f: FieldDecl, raw: unknown, ctx: CoerceCtx, path: string): unknown;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=coerce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../../src/import/coerce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjF,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAGnC,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC;IACrB,4EAA4E;IAC5E,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjE,oGAAoG;IACpG,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACxC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACjC,qFAAqF;IACrF,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,gHAAgH;IAChH,UAAU,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAChC;AAYD,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GAAG,GAAG,CAUpI;AAWD,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAsF7F"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coerceFields = coerceFields;
|
|
4
|
+
exports.coerceValue = coerceValue;
|
|
5
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
6
|
+
const drop = (ctx, path) => ctx.dropped.set(path, (ctx.dropped.get(path) ?? 0) + 1);
|
|
7
|
+
function many(field, raw, one) {
|
|
8
|
+
if (field.hasMany) {
|
|
9
|
+
const list = (Array.isArray(raw) ? raw : raw === undefined || raw === null ? [] : [raw]).map(one).filter((x) => x !== undefined);
|
|
10
|
+
return list;
|
|
11
|
+
}
|
|
12
|
+
return one(Array.isArray(raw) ? raw[0] : raw);
|
|
13
|
+
}
|
|
14
|
+
function coerceFields(fields, raw, ctx, path, skip = new Set()) {
|
|
15
|
+
const out = {};
|
|
16
|
+
const known = new Set(fields.map((f) => f.key));
|
|
17
|
+
for (const f of fields) {
|
|
18
|
+
if (skip.has(f.key) || raw[f.key] === undefined || raw[f.key] === null)
|
|
19
|
+
continue;
|
|
20
|
+
const v = coerceValue(f, raw[f.key], ctx, `${path}.${f.key}`);
|
|
21
|
+
if (v !== undefined && !(Array.isArray(v) && v.length === 0 && f.hasMany))
|
|
22
|
+
out[f.key] = v;
|
|
23
|
+
}
|
|
24
|
+
for (const k of Object.keys(raw))
|
|
25
|
+
if (!known.has(k) && !skip.has(k) && raw[k] !== undefined && raw[k] !== null)
|
|
26
|
+
drop(ctx, `${path}.${k}`);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A list of scalars or files is an array of one-field rows in the model. A raw
|
|
31
|
+
* list of strings, ids or file objects is wrapped into those rows; a raw row
|
|
32
|
+
* that already names the field is left as it is.
|
|
33
|
+
*/
|
|
34
|
+
const WRAPPED = new Set(['media', 'file', 'reference', 'richText', 'json']);
|
|
35
|
+
const ISO = /^\d{4}-\d{2}-\d{2}/;
|
|
36
|
+
function coerceValue(f, raw, ctx, path) {
|
|
37
|
+
const bad = () => {
|
|
38
|
+
drop(ctx, path);
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
switch (f.type) {
|
|
42
|
+
case 'text':
|
|
43
|
+
case 'textarea':
|
|
44
|
+
case 'email':
|
|
45
|
+
case 'select':
|
|
46
|
+
case 'multiselect':
|
|
47
|
+
case 'slug':
|
|
48
|
+
case 'color':
|
|
49
|
+
case 'url':
|
|
50
|
+
case 'phone':
|
|
51
|
+
return many(f, raw, (v) => (typeof v === 'string' ? v : typeof v === 'number' || typeof v === 'boolean' ? String(v) : undefined)) ?? bad();
|
|
52
|
+
case 'number':
|
|
53
|
+
case 'money':
|
|
54
|
+
return many(f, raw, (v) => (typeof v === 'number' && Number.isFinite(v) ? v : typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)) ? Number(v) : undefined)) ?? bad();
|
|
55
|
+
case 'boolean':
|
|
56
|
+
return typeof raw === 'boolean' ? raw : raw === 'true' ? true : raw === 'false' ? false : bad();
|
|
57
|
+
case 'datetime':
|
|
58
|
+
case 'date': {
|
|
59
|
+
const d = typeof raw === 'string' || typeof raw === 'number' ? new Date(raw) : null;
|
|
60
|
+
if (!d || Number.isNaN(d.getTime()))
|
|
61
|
+
return bad();
|
|
62
|
+
// A calendar day stays the day the source wrote, not that day in UTC shifted by a zone.
|
|
63
|
+
return f.type === 'date' ? (typeof raw === 'string' && ISO.test(raw) ? raw.slice(0, 10) : d.toISOString().slice(0, 10)) : d.toISOString();
|
|
64
|
+
}
|
|
65
|
+
case 'code':
|
|
66
|
+
if (typeof raw === 'string')
|
|
67
|
+
return { language: 'text', code: raw };
|
|
68
|
+
return isObj(raw) && typeof raw.code === 'string' ? { language: typeof raw.language === 'string' && raw.language ? raw.language : 'text', code: raw.code } : bad();
|
|
69
|
+
case 'json':
|
|
70
|
+
return raw;
|
|
71
|
+
case 'richText': {
|
|
72
|
+
const doc = ctx.source.richText(raw, ctx.image);
|
|
73
|
+
return doc ?? bad();
|
|
74
|
+
}
|
|
75
|
+
case 'media':
|
|
76
|
+
case 'file': {
|
|
77
|
+
const one = (v) => {
|
|
78
|
+
const id = ctx.source.mediaId(v);
|
|
79
|
+
const asset = id ? ctx.asset(id) : null;
|
|
80
|
+
if (!asset)
|
|
81
|
+
return undefined;
|
|
82
|
+
const alt = isObj(v) && typeof v.alt === 'string' ? v.alt : undefined;
|
|
83
|
+
return f.type === 'file' ? { assetId: asset.id, name: asset.filename } : { assetId: asset.id, ...(alt ? { alt } : {}) };
|
|
84
|
+
};
|
|
85
|
+
return many(f, raw, one) ?? bad();
|
|
86
|
+
}
|
|
87
|
+
case 'reference': {
|
|
88
|
+
const targets = ctx.source.refs(raw, f);
|
|
89
|
+
const ids = [];
|
|
90
|
+
for (const t of targets) {
|
|
91
|
+
const id = ctx.entry(t);
|
|
92
|
+
if (id)
|
|
93
|
+
ids.push({ kind: 'entry', id });
|
|
94
|
+
else
|
|
95
|
+
ctx.pendingRef.value = true;
|
|
96
|
+
}
|
|
97
|
+
if (!targets.length)
|
|
98
|
+
return bad();
|
|
99
|
+
if (!ids.length)
|
|
100
|
+
return undefined;
|
|
101
|
+
return f.hasMany ? ids : ids[0];
|
|
102
|
+
}
|
|
103
|
+
case 'group':
|
|
104
|
+
return isObj(raw) ? coerceFields(f.fields ?? [], raw, ctx, path) : bad();
|
|
105
|
+
case 'array': {
|
|
106
|
+
if (!Array.isArray(raw))
|
|
107
|
+
return bad();
|
|
108
|
+
const only = f.fields?.length === 1 ? f.fields[0] : null;
|
|
109
|
+
return raw
|
|
110
|
+
.map((row) => (only && !(isObj(row) && only.key in row) && (!isObj(row) || WRAPPED.has(only.type)) ? { [only.key]: row } : row))
|
|
111
|
+
.filter(isObj)
|
|
112
|
+
.map((row, i) => coerceFields(f.fields ?? [], row, ctx, `${path}[${i}]`, new Set(['id'])));
|
|
113
|
+
}
|
|
114
|
+
case 'blocks': {
|
|
115
|
+
if (!Array.isArray(raw))
|
|
116
|
+
return bad();
|
|
117
|
+
const rows = [];
|
|
118
|
+
raw.forEach((row, i) => {
|
|
119
|
+
if (!isObj(row))
|
|
120
|
+
return;
|
|
121
|
+
const bt = String(row.blockType ?? row._type ?? '');
|
|
122
|
+
const fields = ctx.blocks.get(bt);
|
|
123
|
+
if (!fields)
|
|
124
|
+
return void drop(ctx, `${path}[${i}]<${bt || 'unnamed block'}>`);
|
|
125
|
+
rows.push({ blockType: bt, ...coerceFields(fields, row, ctx, `${path}[${i}]<${bt}>`, new Set(['id', 'blockType', 'blockName', '_type', '_key'])) });
|
|
126
|
+
});
|
|
127
|
+
return rows;
|
|
128
|
+
}
|
|
129
|
+
default:
|
|
130
|
+
// seo, link, form… have shapes only the author's model knows; a value already in that shape passes.
|
|
131
|
+
return raw;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=coerce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.js","sourceRoot":"","sources":["../../src/import/coerce.ts"],"names":[],"mappings":";;AAuCA,oCAUC;AAWD,kCAsFC;AArID,MAAM,KAAK,GAAG,CAAC,CAAU,EAAY,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,O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AAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACtJ,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;QACD;YACE,oGAAoG;YACpG,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ForumulateClient } from '@forumulate/sdk';
|
|
2
|
+
import type { ImportFiles, ImportSource } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* `forumulate import <platform> <path> --library <id|slug>` (plan P4-T3, T4).
|
|
5
|
+
*
|
|
6
|
+
* Reads the export, shows what the model needs and what would land (a dry run
|
|
7
|
+
* is always the first step), and writes only after a yes or `--yes`. Talks to
|
|
8
|
+
* the library through the same management API every other client uses.
|
|
9
|
+
*/
|
|
10
|
+
export interface ImportDeps {
|
|
11
|
+
client: ForumulateClient;
|
|
12
|
+
out: (line: string) => void;
|
|
13
|
+
err: (line: string) => void;
|
|
14
|
+
env?: NodeJS.ProcessEnv;
|
|
15
|
+
ask?: (question: string) => Promise<string>;
|
|
16
|
+
upload?: (path: string, form: FormData) => Promise<unknown>;
|
|
17
|
+
sleep?: (ms: number) => Promise<void>;
|
|
18
|
+
files?: ImportFiles;
|
|
19
|
+
fetchBytes?: (url: string) => Promise<Uint8Array>;
|
|
20
|
+
}
|
|
21
|
+
export declare const IMPORT_PLATFORMS: readonly ["payload", "contentful", "sanity", "strapi", "wordpress"];
|
|
22
|
+
export declare const IMPORT_VALUE_FLAGS: string[];
|
|
23
|
+
export declare function readSource(platform: string, path: string, argv: readonly string[], files: ImportFiles): ImportSource;
|
|
24
|
+
export declare function runImportCommand(argv: readonly string[], positional: readonly string[], deps: ImportDeps): Promise<number>;
|
|
25
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/import/command.ts"],"names":[],"mapp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