@wp-typia/project-tools 0.19.0 → 0.19.2
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/runtime/block-generator-service-spec.js +206 -2
- package/dist/runtime/built-in-block-artifacts.js +3 -1
- package/dist/runtime/built-in-block-code-artifacts.js +3 -1
- package/dist/runtime/built-in-block-non-ts-artifacts.js +1 -1039
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +30 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +1035 -0
- package/dist/runtime/built-in-block-non-ts-render-utils.d.ts +27 -0
- package/dist/runtime/built-in-block-non-ts-render-utils.js +51 -0
- package/dist/runtime/cli-add-block.js +11 -5
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +3 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.js +188 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +379 -0
- package/dist/runtime/cli-add-workspace-rest.js +5 -564
- package/dist/runtime/cli-diagnostics.d.ts +26 -0
- package/dist/runtime/cli-diagnostics.js +107 -0
- package/dist/runtime/cli-doctor-workspace.js +4 -4
- package/dist/runtime/cli-scaffold.js +3 -3
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/scaffold-bootstrap.js +5 -1
- package/dist/runtime/scaffold-documents.js +11 -8
- package/dist/runtime/scaffold-template-variable-groups.d.ts +154 -0
- package/dist/runtime/scaffold-template-variable-groups.js +13 -0
- package/dist/runtime/scaffold-template-variables.js +58 -1
- package/dist/runtime/scaffold.d.ts +5 -1
- package/dist/runtime/scaffold.js +5 -1
- package/dist/runtime/temp-roots.d.ts +44 -0
- package/dist/runtime/temp-roots.js +129 -0
- package/dist/runtime/template-builtins.js +4 -6
- package/dist/runtime/template-registry.d.ts +8 -0
- package/dist/runtime/template-registry.js +34 -1
- package/dist/runtime/template-source-external.d.ts +1 -0
- package/dist/runtime/template-source-external.js +4 -7
- package/dist/runtime/template-source-remote.js +44 -23
- package/dist/runtime/template-source-seeds.js +3 -9
- package/dist/runtime/template-source.d.ts +2 -3
- package/dist/runtime/template-source.js +8 -2
- package/package.json +6 -1
|
@@ -5,6 +5,7 @@ import { DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDe
|
|
|
5
5
|
import { getTemplateById, } from "./template-registry.js";
|
|
6
6
|
import { toPascalCase, toSnakeCase, } from "./string-case.js";
|
|
7
7
|
import { buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, } from "./scaffold-identifiers.js";
|
|
8
|
+
import { attachScaffoldTemplateVariableGroups } from "./scaffold-template-variable-groups.js";
|
|
8
9
|
function getBuiltInPersistenceSpec({ templateId, dataStorageMode, persistencePolicy, }) {
|
|
9
10
|
if (templateId === "persistence") {
|
|
10
11
|
return {
|
|
@@ -114,13 +115,14 @@ export function buildTemplateVariablesFromBlockSpec(spec) {
|
|
|
114
115
|
const compoundChildCssClassName = buildBlockCssClassName(namespace, `${slug}-item`);
|
|
115
116
|
const compoundInnerBlocksPreset = spec.compound.innerBlocksPreset;
|
|
116
117
|
const compoundInnerBlocksPresetDefinition = getCompoundInnerBlocksPresetDefinition(compoundInnerBlocksPreset);
|
|
118
|
+
const compoundInnerBlocksOrientation = compoundInnerBlocksPresetDefinition.orientation ?? "";
|
|
117
119
|
const persistenceEnabled = spec.persistence.enabled;
|
|
118
120
|
const dataStorageMode = persistenceEnabled ? spec.persistence.dataStorageMode : "custom-table";
|
|
119
121
|
const persistencePolicy = persistenceEnabled
|
|
120
122
|
? spec.persistence.persistencePolicy
|
|
121
123
|
: "authenticated";
|
|
122
124
|
const queryVariationNamespace = `${namespace}/${slug}`;
|
|
123
|
-
|
|
125
|
+
const flatVariables = {
|
|
124
126
|
alternateRenderTargetsCsv: formatAlternateRenderTargets(alternateRenderTargets),
|
|
125
127
|
alternateRenderTargetsJson: JSON.stringify(alternateRenderTargets),
|
|
126
128
|
apiClientPackageVersion,
|
|
@@ -137,7 +139,7 @@ export function buildTemplateVariablesFromBlockSpec(spec) {
|
|
|
137
139
|
compoundChildTitleJson: JSON.stringify(compoundChildTitle),
|
|
138
140
|
compoundPersistenceEnabled: spec.template.family === "compound" && persistenceEnabled ? "true" : "false",
|
|
139
141
|
compoundInnerBlocksDirectInsert: compoundInnerBlocksPresetDefinition.directInsert ? "true" : "false",
|
|
140
|
-
compoundInnerBlocksOrientation:
|
|
142
|
+
compoundInnerBlocksOrientation: compoundInnerBlocksOrientation,
|
|
141
143
|
compoundInnerBlocksOrientationExpression: compoundInnerBlocksPresetDefinition.orientation
|
|
142
144
|
? `'${compoundInnerBlocksPresetDefinition.orientation}'`
|
|
143
145
|
: "undefined",
|
|
@@ -205,4 +207,206 @@ export function buildTemplateVariablesFromBlockSpec(spec) {
|
|
|
205
207
|
titleCase: pascalCase,
|
|
206
208
|
persistencePolicy,
|
|
207
209
|
};
|
|
210
|
+
const shared = {
|
|
211
|
+
author: spec.project.author,
|
|
212
|
+
blockMetadataVersion: BUILTIN_BLOCK_METADATA_VERSION,
|
|
213
|
+
category: spec.metadata.category,
|
|
214
|
+
cssClassName,
|
|
215
|
+
description: spec.metadata.description,
|
|
216
|
+
descriptionJson: flatVariables.descriptionJson,
|
|
217
|
+
frontendCssClassName: flatVariables.frontendCssClassName,
|
|
218
|
+
icon: spec.metadata.icon,
|
|
219
|
+
keyword: spec.metadata.keyword,
|
|
220
|
+
namespace,
|
|
221
|
+
pascalCase,
|
|
222
|
+
phpPrefix,
|
|
223
|
+
phpPrefixUpper,
|
|
224
|
+
slug,
|
|
225
|
+
slugCamelCase: flatVariables.slugCamelCase,
|
|
226
|
+
slugKebabCase: slug,
|
|
227
|
+
slugSnakeCase,
|
|
228
|
+
textDomain,
|
|
229
|
+
title,
|
|
230
|
+
titleCase: pascalCase,
|
|
231
|
+
titleJson: flatVariables.titleJson,
|
|
232
|
+
versions: {
|
|
233
|
+
apiClient: apiClientPackageVersion,
|
|
234
|
+
blockRuntime: blockRuntimePackageVersion,
|
|
235
|
+
blockTypes: blockTypesPackageVersion,
|
|
236
|
+
projectTools: projectToolsPackageVersion,
|
|
237
|
+
rest: restPackageVersion,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
const alternateRenderTargetsGroup = {
|
|
241
|
+
csv: flatVariables.alternateRenderTargetsCsv,
|
|
242
|
+
enabled: alternateRenderTargets.length > 0,
|
|
243
|
+
hasEmail: hasAlternateEmailRenderTarget,
|
|
244
|
+
hasMjml: hasAlternateMjmlRenderTarget,
|
|
245
|
+
hasPlainText: hasAlternatePlainTextRenderTarget,
|
|
246
|
+
json: flatVariables.alternateRenderTargetsJson,
|
|
247
|
+
targets: alternateRenderTargets,
|
|
248
|
+
};
|
|
249
|
+
const compoundGroup = {
|
|
250
|
+
child: {
|
|
251
|
+
category: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.category,
|
|
252
|
+
cssClassName: compoundChildCssClassName,
|
|
253
|
+
icon: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.icon,
|
|
254
|
+
title: compoundChildTitle,
|
|
255
|
+
titleJson: JSON.stringify(compoundChildTitle),
|
|
256
|
+
},
|
|
257
|
+
enabled: true,
|
|
258
|
+
innerBlocks: {
|
|
259
|
+
description: compoundInnerBlocksPresetDefinition.description,
|
|
260
|
+
directInsert: compoundInnerBlocksPresetDefinition.directInsert,
|
|
261
|
+
label: compoundInnerBlocksPresetDefinition.label,
|
|
262
|
+
orientation: compoundInnerBlocksOrientation,
|
|
263
|
+
orientationExpression: compoundInnerBlocksPresetDefinition.orientation
|
|
264
|
+
? `'${compoundInnerBlocksPresetDefinition.orientation}'`
|
|
265
|
+
: "undefined",
|
|
266
|
+
preset: compoundInnerBlocksPreset,
|
|
267
|
+
templateLockExpression: compoundInnerBlocksPresetDefinition.templateLock === false
|
|
268
|
+
? "false"
|
|
269
|
+
: `'${compoundInnerBlocksPresetDefinition.templateLock}'`,
|
|
270
|
+
},
|
|
271
|
+
persistenceEnabled: persistenceEnabled,
|
|
272
|
+
};
|
|
273
|
+
const persistenceGroup = persistenceEnabled
|
|
274
|
+
? {
|
|
275
|
+
auth: {
|
|
276
|
+
bootstrapCredentialDeclarations: flatVariables.bootstrapCredentialDeclarations,
|
|
277
|
+
descriptionJson: flatVariables.persistencePolicyDescriptionJson,
|
|
278
|
+
intent: flatVariables.restWriteAuthIntent,
|
|
279
|
+
isAuthenticated: persistencePolicy === "authenticated",
|
|
280
|
+
isPublic: persistencePolicy === "public",
|
|
281
|
+
mechanism: flatVariables.restWriteAuthMechanism,
|
|
282
|
+
mode: flatVariables.restWriteAuthMode,
|
|
283
|
+
publicWriteRequestIdDeclaration: flatVariables.publicWriteRequestIdDeclaration,
|
|
284
|
+
},
|
|
285
|
+
dataStorageMode,
|
|
286
|
+
enabled: true,
|
|
287
|
+
policy: persistencePolicy,
|
|
288
|
+
scope: spec.persistence.scope,
|
|
289
|
+
}
|
|
290
|
+
: null;
|
|
291
|
+
const queryLoopGroup = {
|
|
292
|
+
allowedControls: spec.queryLoop.allowedControls,
|
|
293
|
+
allowedControlsJson: flatVariables.queryAllowedControlsJson,
|
|
294
|
+
enabled: true,
|
|
295
|
+
postType: spec.queryLoop.postType,
|
|
296
|
+
postTypeJson: flatVariables.queryPostTypeJson,
|
|
297
|
+
variationNamespace: queryVariationNamespace,
|
|
298
|
+
variationNamespaceJson: flatVariables.queryVariationNamespaceJson,
|
|
299
|
+
};
|
|
300
|
+
switch (spec.template.family) {
|
|
301
|
+
case "basic":
|
|
302
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
303
|
+
alternateRenderTargets: alternateRenderTargetsGroup,
|
|
304
|
+
compound: {
|
|
305
|
+
enabled: false,
|
|
306
|
+
persistenceEnabled: false,
|
|
307
|
+
},
|
|
308
|
+
persistence: {
|
|
309
|
+
enabled: false,
|
|
310
|
+
scope: "none",
|
|
311
|
+
},
|
|
312
|
+
queryLoop: {
|
|
313
|
+
enabled: false,
|
|
314
|
+
},
|
|
315
|
+
shared,
|
|
316
|
+
template: {
|
|
317
|
+
description: spec.template.description,
|
|
318
|
+
},
|
|
319
|
+
templateFamily: "basic",
|
|
320
|
+
});
|
|
321
|
+
case "interactivity":
|
|
322
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
323
|
+
alternateRenderTargets: alternateRenderTargetsGroup,
|
|
324
|
+
compound: {
|
|
325
|
+
enabled: false,
|
|
326
|
+
persistenceEnabled: false,
|
|
327
|
+
},
|
|
328
|
+
persistence: {
|
|
329
|
+
enabled: false,
|
|
330
|
+
scope: "none",
|
|
331
|
+
},
|
|
332
|
+
queryLoop: {
|
|
333
|
+
enabled: false,
|
|
334
|
+
},
|
|
335
|
+
shared,
|
|
336
|
+
template: {
|
|
337
|
+
description: spec.template.description,
|
|
338
|
+
},
|
|
339
|
+
templateFamily: "interactivity",
|
|
340
|
+
});
|
|
341
|
+
case "persistence": {
|
|
342
|
+
if (persistenceGroup === null) {
|
|
343
|
+
throw new Error("Persistence scaffolds must provide persistence template variables.");
|
|
344
|
+
}
|
|
345
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
346
|
+
alternateRenderTargets: alternateRenderTargetsGroup,
|
|
347
|
+
compound: {
|
|
348
|
+
enabled: false,
|
|
349
|
+
persistenceEnabled: false,
|
|
350
|
+
},
|
|
351
|
+
persistence: {
|
|
352
|
+
...persistenceGroup,
|
|
353
|
+
scope: "single",
|
|
354
|
+
},
|
|
355
|
+
queryLoop: {
|
|
356
|
+
enabled: false,
|
|
357
|
+
},
|
|
358
|
+
shared,
|
|
359
|
+
template: {
|
|
360
|
+
description: spec.template.description,
|
|
361
|
+
},
|
|
362
|
+
templateFamily: "persistence",
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
case "compound": {
|
|
366
|
+
const compoundPersistenceGroup = persistenceGroup === null
|
|
367
|
+
? {
|
|
368
|
+
enabled: false,
|
|
369
|
+
scope: "none",
|
|
370
|
+
}
|
|
371
|
+
: {
|
|
372
|
+
...persistenceGroup,
|
|
373
|
+
scope: "compound-parent",
|
|
374
|
+
};
|
|
375
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
376
|
+
alternateRenderTargets: alternateRenderTargetsGroup,
|
|
377
|
+
compound: compoundGroup,
|
|
378
|
+
persistence: compoundPersistenceGroup,
|
|
379
|
+
queryLoop: {
|
|
380
|
+
enabled: false,
|
|
381
|
+
},
|
|
382
|
+
shared,
|
|
383
|
+
template: {
|
|
384
|
+
description: spec.template.description,
|
|
385
|
+
},
|
|
386
|
+
templateFamily: "compound",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
case "query-loop":
|
|
390
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
391
|
+
alternateRenderTargets: alternateRenderTargetsGroup,
|
|
392
|
+
compound: {
|
|
393
|
+
enabled: false,
|
|
394
|
+
persistenceEnabled: false,
|
|
395
|
+
},
|
|
396
|
+
persistence: {
|
|
397
|
+
enabled: false,
|
|
398
|
+
scope: "none",
|
|
399
|
+
},
|
|
400
|
+
queryLoop: queryLoopGroup,
|
|
401
|
+
shared,
|
|
402
|
+
template: {
|
|
403
|
+
description: spec.template.description,
|
|
404
|
+
},
|
|
405
|
+
templateFamily: "query-loop",
|
|
406
|
+
});
|
|
407
|
+
default: {
|
|
408
|
+
const unreachableTemplateFamily = spec.template.family;
|
|
409
|
+
throw new Error(`Unhandled scaffold template family: ${unreachableTemplateFamily}`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
208
412
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildBasicAttributes, buildBlockJsonAttributes, buildCompoundChildAttributes, buildCompoundParentAttributes, buildInteractivityAttributes, buildManifestDocument, buildPersistenceAttributes, DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, } from "./built-in-block-artifact-documents.js";
|
|
2
2
|
import { buildBasicTypesSource, buildCompoundChildTypesSource, buildCompoundTypesSource, buildInteractivityTypesSource, buildPersistenceTypesSource, } from "./built-in-block-artifact-types.js";
|
|
3
|
+
import { getScaffoldTemplateVariableGroups } from "./scaffold-template-variable-groups.js";
|
|
3
4
|
function stringifyBlockJsonDocument(document) {
|
|
4
5
|
return `${JSON.stringify(document, null, "\t")}\n`;
|
|
5
6
|
}
|
|
@@ -103,7 +104,8 @@ function buildPersistenceArtifact(variables) {
|
|
|
103
104
|
}
|
|
104
105
|
function buildCompoundParentArtifact(variables) {
|
|
105
106
|
const attributes = buildCompoundParentAttributes(variables);
|
|
106
|
-
const
|
|
107
|
+
const compoundGroup = getScaffoldTemplateVariableGroups(variables).compound;
|
|
108
|
+
const persistenceEnabled = compoundGroup.enabled && compoundGroup.persistenceEnabled;
|
|
107
109
|
return {
|
|
108
110
|
blockJsonDocument: {
|
|
109
111
|
$schema: "https://schemas.wp.org/trunk/block.json",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildBuiltInNonTsArtifacts } from "./built-in-block-non-ts-artifacts.js";
|
|
2
2
|
import { BASIC_EDIT_TEMPLATE, BASIC_INDEX_TEMPLATE, BASIC_SAVE_TEMPLATE, BASIC_VALIDATORS_TEMPLATE, BLOCK_METADATA_WRAPPER_TEMPLATE, COMPOUND_CHILD_EDIT_TEMPLATE, COMPOUND_CHILD_INDEX_TEMPLATE, COMPOUND_CHILD_SAVE_TEMPLATE, COMPOUND_CHILD_VALIDATORS_TEMPLATE, COMPOUND_CHILDREN_TEMPLATE, COMPOUND_LOCAL_HOOKS_TEMPLATE, COMPOUND_PARENT_EDIT_TEMPLATE, COMPOUND_PARENT_INDEX_TEMPLATE, COMPOUND_PARENT_SAVE_TEMPLATE, COMPOUND_PARENT_VALIDATORS_TEMPLATE, COMPOUND_PERSISTENCE_PARENT_EDIT_TEMPLATE, COMPOUND_PERSISTENCE_PARENT_INTERACTIVITY_TEMPLATE, COMPOUND_PERSISTENCE_PARENT_SAVE_TEMPLATE, COMPOUND_PERSISTENCE_PARENT_VALIDATORS_TEMPLATE, INTERACTIVITY_EDIT_TEMPLATE, INTERACTIVITY_INDEX_TEMPLATE, INTERACTIVITY_SAVE_TEMPLATE, INTERACTIVITY_SCRIPT_TEMPLATE, INTERACTIVITY_VALIDATORS_TEMPLATE, MANIFEST_DEFAULTS_DOCUMENT_WRAPPER_TEMPLATE, MANIFEST_DOCUMENT_WRAPPER_TEMPLATE, PERSISTENCE_EDIT_TEMPLATE, PERSISTENCE_INDEX_TEMPLATE, PERSISTENCE_INTERACTIVITY_TEMPLATE, PERSISTENCE_SAVE_TEMPLATE, PERSISTENCE_VALIDATORS_TEMPLATE, QUERY_LOOP_INDEX_TEMPLATE, SHARED_HOOKS_TEMPLATE, } from "./built-in-block-code-templates.js";
|
|
3
|
+
import { getScaffoldTemplateVariableGroups } from "./scaffold-template-variable-groups.js";
|
|
3
4
|
import { renderMustacheTemplateString } from "./template-render.js";
|
|
4
5
|
function renderCodeTemplate(template, variables) {
|
|
5
6
|
const rendered = renderMustacheTemplateString(template, variables);
|
|
@@ -98,7 +99,8 @@ function buildInteractivityCodeArtifacts(variables) {
|
|
|
98
99
|
function buildCompoundCodeArtifacts(variables) {
|
|
99
100
|
const parentBasePath = `src/blocks/${variables.slugKebabCase}`;
|
|
100
101
|
const childBasePath = `src/blocks/${variables.slugKebabCase}-item`;
|
|
101
|
-
const
|
|
102
|
+
const compoundGroup = getScaffoldTemplateVariableGroups(variables).compound;
|
|
103
|
+
const compoundPersistenceEnabled = compoundGroup.enabled && compoundGroup.persistenceEnabled;
|
|
102
104
|
return ensureUniqueArtifactPaths([
|
|
103
105
|
createCodeArtifact("src/hooks.ts", SHARED_HOOKS_TEMPLATE, variables),
|
|
104
106
|
...createTypedJsonWrapperArtifacts(parentBasePath, variables),
|