@signstack/cli 0.1.1
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 +458 -0
- package/bin/run.js +12 -0
- package/dist/apps/signstack-cli/schemas/asset.schema.json +220 -0
- package/dist/apps/signstack-cli/schemas/blueprint.schema.json +485 -0
- package/dist/apps/signstack-cli/schemas/jsonata-function.schema.json +185 -0
- package/dist/apps/signstack-cli/schemas/schema.schema.json +97 -0
- package/dist/apps/signstack-cli/schemas/template.schema.json +295 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.d.ts +25 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.js +229 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.d.ts +10 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.js +59 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.d.ts +9 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.js +85 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/generate.d.ts +51 -0
- package/dist/apps/signstack-cli/src/commands/generate.js +479 -0
- package/dist/apps/signstack-cli/src/commands/generate.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/preview.d.ts +24 -0
- package/dist/apps/signstack-cli/src/commands/preview.js +162 -0
- package/dist/apps/signstack-cli/src/commands/preview.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/pull.d.ts +28 -0
- package/dist/apps/signstack-cli/src/commands/pull.js +244 -0
- package/dist/apps/signstack-cli/src/commands/pull.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/push.d.ts +46 -0
- package/dist/apps/signstack-cli/src/commands/push.js +460 -0
- package/dist/apps/signstack-cli/src/commands/push.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/run.d.ts +22 -0
- package/dist/apps/signstack-cli/src/commands/run.js +126 -0
- package/dist/apps/signstack-cli/src/commands/run.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/test.d.ts +6 -0
- package/dist/apps/signstack-cli/src/commands/test.js +25 -0
- package/dist/apps/signstack-cli/src/commands/test.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/validate.d.ts +59 -0
- package/dist/apps/signstack-cli/src/commands/validate.js +558 -0
- package/dist/apps/signstack-cli/src/commands/validate.js.map +1 -0
- package/dist/apps/signstack-cli/src/index.d.ts +1 -0
- package/dist/apps/signstack-cli/src/index.js +2 -0
- package/dist/apps/signstack-cli/src/index.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/api-client.d.ts +77 -0
- package/dist/apps/signstack-cli/src/lib/api-client.js +269 -0
- package/dist/apps/signstack-cli/src/lib/api-client.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/base-command.d.ts +38 -0
- package/dist/apps/signstack-cli/src/lib/base-command.js +135 -0
- package/dist/apps/signstack-cli/src/lib/base-command.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/config.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/config.js +106 -0
- package/dist/apps/signstack-cli/src/lib/config.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.d.ts +31 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.js +107 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.d.ts +72 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.js +238 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.d.ts +4 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.js +7 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.d.ts +127 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.js +545 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.d.ts +95 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.js +611 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.d.ts +63 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.js +198 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.d.ts +13 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.js +39 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.d.ts +131 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.js +800 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.d.ts +87 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.js +361 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.d.ts +29 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.js +101 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.d.ts +44 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.js +158 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.js +266 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.d.ts +28 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.js +44 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.d.ts +35 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.js +80 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.d.ts +8 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.js +39 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.d.ts +17 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.js +61 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.d.ts +25 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.js +133 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.d.ts +3 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.js +32 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.js +160 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/auth.types.d.ts +48 -0
- package/dist/apps/signstack-cli/src/types/auth.types.js +31 -0
- package/dist/apps/signstack-cli/src/types/auth.types.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/schema.types.d.ts +14 -0
- package/dist/apps/signstack-cli/src/types/schema.types.js +16 -0
- package/dist/apps/signstack-cli/src/types/schema.types.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.d.ts +144 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.js +2 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.js.map +1 -0
- package/dist/libs/common/base/src/index.d.ts +14 -0
- package/dist/libs/common/base/src/index.js +44 -0
- package/dist/libs/common/base/src/index.js.map +1 -0
- package/dist/libs/common/base/src/lib/address.util.d.ts +12 -0
- package/dist/libs/common/base/src/lib/address.util.js +55 -0
- package/dist/libs/common/base/src/lib/address.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/country-code-data.d.ts +5 -0
- package/dist/libs/common/base/src/lib/country-code-data.js +1256 -0
- package/dist/libs/common/base/src/lib/country-code-data.js.map +1 -0
- package/dist/libs/common/base/src/lib/date.util.d.ts +13 -0
- package/dist/libs/common/base/src/lib/date.util.js +135 -0
- package/dist/libs/common/base/src/lib/date.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/headers.d.ts +1 -0
- package/dist/libs/common/base/src/lib/headers.js +5 -0
- package/dist/libs/common/base/src/lib/headers.js.map +1 -0
- package/dist/libs/common/base/src/lib/jsonata.service.d.ts +32 -0
- package/dist/libs/common/base/src/lib/jsonata.service.js +207 -0
- package/dist/libs/common/base/src/lib/jsonata.service.js.map +1 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.d.ts +37 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.js +144 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.js.map +1 -0
- package/dist/libs/common/base/src/lib/phone-util.d.ts +16 -0
- package/dist/libs/common/base/src/lib/phone-util.js +61 -0
- package/dist/libs/common/base/src/lib/phone-util.js.map +1 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.d.ts +24 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.js +155 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/string-builder.d.ts +48 -0
- package/dist/libs/common/base/src/lib/string-builder.js +90 -0
- package/dist/libs/common/base/src/lib/string-builder.js.map +1 -0
- package/dist/libs/common/base/src/lib/util.d.ts +20 -0
- package/dist/libs/common/base/src/lib/util.js +110 -0
- package/dist/libs/common/base/src/lib/util.js.map +1 -0
- package/dist/libs/signstack/base/schemas/asset.schema.json +220 -0
- package/dist/libs/signstack/base/schemas/blueprint.schema.json +485 -0
- package/dist/libs/signstack/base/schemas/jsonata-function.schema.json +185 -0
- package/dist/libs/signstack/base/schemas/schema.schema.json +97 -0
- package/dist/libs/signstack/base/schemas/template.schema.json +295 -0
- package/dist/libs/signstack/base/src/index.d.ts +28 -0
- package/dist/libs/signstack/base/src/index.js +32 -0
- package/dist/libs/signstack/base/src/index.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/constants.d.ts +123 -0
- package/dist/libs/signstack/base/src/lib/constants.js +131 -0
- package/dist/libs/signstack/base/src/lib/constants.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/hash.util.d.ts +58 -0
- package/dist/libs/signstack/base/src/lib/hash.util.js +90 -0
- package/dist/libs/signstack/base/src/lib/hash.util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.d.ts +29 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.js +93 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.d.ts +41 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.d.ts +54 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.js +18 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/asset.d.ts +101 -0
- package/dist/libs/signstack/base/src/lib/models/asset.js +11 -0
- package/dist/libs/signstack/base/src/lib/models/asset.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/auth.d.ts +142 -0
- package/dist/libs/signstack/base/src/lib/models/auth.js +35 -0
- package/dist/libs/signstack/base/src/lib/models/auth.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/base.d.ts +134 -0
- package/dist/libs/signstack/base/src/lib/models/base.js +71 -0
- package/dist/libs/signstack/base/src/lib/models/base.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.d.ts +311 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.js +9 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/file.d.ts +75 -0
- package/dist/libs/signstack/base/src/lib/models/file.js +9 -0
- package/dist/libs/signstack/base/src/lib/models/file.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.d.ts +111 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.js +19 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.d.ts +132 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.js +22 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/membership.d.ts +127 -0
- package/dist/libs/signstack/base/src/lib/models/membership.js +22 -0
- package/dist/libs/signstack/base/src/lib/models/membership.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.d.ts +87 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.js +57 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/organization.d.ts +79 -0
- package/dist/libs/signstack/base/src/lib/models/organization.js +41 -0
- package/dist/libs/signstack/base/src/lib/models/organization.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.d.ts +88 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.d.ts +60 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.js +202 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.d.ts +138 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.js +14 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/schema.d.ts +131 -0
- package/dist/libs/signstack/base/src/lib/models/schema.js +44 -0
- package/dist/libs/signstack/base/src/lib/models/schema.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.d.ts +215 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.js +27 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.d.ts +279 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.js +105 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/template.d.ts +248 -0
- package/dist/libs/signstack/base/src/lib/models/template.js +32 -0
- package/dist/libs/signstack/base/src/lib/models/template.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/user.d.ts +30 -0
- package/dist/libs/signstack/base/src/lib/models/user.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/user.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.d.ts +223 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.js +62 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.d.ts +917 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.js +152 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/util.d.ts +92 -0
- package/dist/libs/signstack/base/src/lib/util.js +406 -0
- package/dist/libs/signstack/base/src/lib/util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.d.ts +94 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.js +446 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.d.ts +57 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.js +8 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/index.d.ts +9 -0
- package/dist/libs/signstack/base/src/lib/validation/index.js +23 -0
- package/dist/libs/signstack/base/src/lib/validation/index.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.d.ts +3 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.js +27 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.d.ts +57 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.js +57 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.d.ts +38 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.js +146 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.d.ts +22 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.js +69 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.d.ts +37 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.js +250 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.d.ts +24 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.js +98 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.d.ts +12 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.js +50 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.d.ts +101 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.js +998 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.js.map +1 -0
- package/oclif.manifest.json +822 -0
- package/package.json +101 -0
|
@@ -0,0 +1,998 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitKeyVersion = splitKeyVersion;
|
|
4
|
+
exports.normalizeExpression = normalizeExpression;
|
|
5
|
+
exports.extractExpressionString = extractExpressionString;
|
|
6
|
+
exports.extractBlueprintInputKey = extractBlueprintInputKey;
|
|
7
|
+
exports.resolveRequired = resolveRequired;
|
|
8
|
+
exports.transformInputs = transformInputs;
|
|
9
|
+
exports.transformExpressionInputs = transformExpressionInputs;
|
|
10
|
+
exports.transformRole = transformRole;
|
|
11
|
+
exports.transformField = transformField;
|
|
12
|
+
exports.transformAssetObjectRefs = transformAssetObjectRefs;
|
|
13
|
+
exports.transformPartialObjectRefs = transformPartialObjectRefs;
|
|
14
|
+
exports.transformEnvelopes = transformEnvelopes;
|
|
15
|
+
exports.transformParticipants = transformParticipants;
|
|
16
|
+
exports.transformCustomFields = transformCustomFields;
|
|
17
|
+
exports.transformOrchestrationToTree = transformOrchestrationToTree;
|
|
18
|
+
exports.transformAction = transformAction;
|
|
19
|
+
exports.transformJsonataParams = transformJsonataParams;
|
|
20
|
+
exports.transformJsonataReturnType = transformJsonataReturnType;
|
|
21
|
+
exports.buildHtmlConfigRefs = buildHtmlConfigRefs;
|
|
22
|
+
exports.normalizeYamlFunctionsBlock = normalizeYamlFunctionsBlock;
|
|
23
|
+
exports.convertYamlSpec = convertYamlSpec;
|
|
24
|
+
exports.displayNameToResourceKind = displayNameToResourceKind;
|
|
25
|
+
exports.resourceKindToDisplayName = resourceKindToDisplayName;
|
|
26
|
+
exports.convertResourceToYamlObject = convertResourceToYamlObject;
|
|
27
|
+
exports.resourceToYaml = resourceToYaml;
|
|
28
|
+
const base_1 = require("./models/base");
|
|
29
|
+
const jsonata_function_1 = require("./models/jsonata-function");
|
|
30
|
+
const resource_edge_1 = require("./models/resource-edge");
|
|
31
|
+
const yaml_1 = require("yaml");
|
|
32
|
+
const workflow_1 = require("./models/workflow");
|
|
33
|
+
const util_1 = require("./util");
|
|
34
|
+
// ─── Utility Functions ──────────────────────────────────────────────
|
|
35
|
+
const JSONPATH_ROOT_SEGMENT = /^\$\.([^.[\]]+)/;
|
|
36
|
+
function splitKeyVersion(ref) {
|
|
37
|
+
if (!ref || typeof ref !== 'string')
|
|
38
|
+
return { key: ref, version: '' };
|
|
39
|
+
const [key, version] = ref.split('@');
|
|
40
|
+
return { key, version: version || '' };
|
|
41
|
+
}
|
|
42
|
+
function normalizeExpression(value) {
|
|
43
|
+
if (value === undefined || value === null)
|
|
44
|
+
return undefined;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function extractExpressionString(value) {
|
|
48
|
+
if (!value)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (typeof value === 'object' && 'expression' in value)
|
|
51
|
+
return value.expression;
|
|
52
|
+
return String(value);
|
|
53
|
+
}
|
|
54
|
+
function extractBlueprintInputKey(value) {
|
|
55
|
+
return value.match(JSONPATH_ROOT_SEGMENT)?.[1] ?? '';
|
|
56
|
+
}
|
|
57
|
+
function resolveRequired(required) {
|
|
58
|
+
if (typeof required === 'boolean')
|
|
59
|
+
return required;
|
|
60
|
+
const resolved = normalizeExpression(required);
|
|
61
|
+
if (util_1.Util.isExpression(resolved))
|
|
62
|
+
return resolved;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
// ─── Transform Helpers ──────────────────────────────────────────────
|
|
66
|
+
function transformInputs(yamlInputs) {
|
|
67
|
+
return yamlInputs.map((i) => {
|
|
68
|
+
const ref = typeof i.schema === 'string'
|
|
69
|
+
? splitKeyVersion(i.schema)
|
|
70
|
+
: { key: '', version: '' };
|
|
71
|
+
return {
|
|
72
|
+
key: i.key,
|
|
73
|
+
schemaKey: i.schemaKey ?? ref.key,
|
|
74
|
+
schemaVersion: i.schemaVersion ?? ref.version,
|
|
75
|
+
name: i.name,
|
|
76
|
+
description: i.description,
|
|
77
|
+
required: resolveRequired(i.required),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Like transformInputs but supports expression-based required fields.
|
|
83
|
+
* Used for template inputs where required can be `{ expression: "..." }`.
|
|
84
|
+
* @deprecated Use transformInputs instead — both now support expressions.
|
|
85
|
+
*/
|
|
86
|
+
function transformExpressionInputs(yamlInputs) {
|
|
87
|
+
return transformInputs(yamlInputs);
|
|
88
|
+
}
|
|
89
|
+
function transformRole(role) {
|
|
90
|
+
const output = role.output
|
|
91
|
+
? {
|
|
92
|
+
schemaKey: role.output.schemaKey ?? role.output.schema?.split('@')?.[0],
|
|
93
|
+
schemaVersion: role.output.schemaVersion ?? role.output.schema?.split('@')?.[1],
|
|
94
|
+
transform: role.output.transform ?? '',
|
|
95
|
+
}
|
|
96
|
+
: undefined;
|
|
97
|
+
return {
|
|
98
|
+
key: role.key,
|
|
99
|
+
name: role.name,
|
|
100
|
+
roleCategory: role.roleCategory ?? 'signer',
|
|
101
|
+
output,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function transformField(field) {
|
|
105
|
+
// Handle both API format (widgets array) and CLI format (single widget object)
|
|
106
|
+
let widgets;
|
|
107
|
+
if (Array.isArray(field.widgets)) {
|
|
108
|
+
widgets = field.widgets;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const widget = field.widget;
|
|
112
|
+
widgets = widget
|
|
113
|
+
? [
|
|
114
|
+
{
|
|
115
|
+
position: {
|
|
116
|
+
pageNumber: widget.page ?? 1,
|
|
117
|
+
x: widget.x ?? 0,
|
|
118
|
+
y: widget.y ?? 0,
|
|
119
|
+
},
|
|
120
|
+
dimensions: {
|
|
121
|
+
width: widget.width ?? 200,
|
|
122
|
+
height: widget.height ?? 20,
|
|
123
|
+
},
|
|
124
|
+
rotationDegree: widget.rotation ?? 0,
|
|
125
|
+
style: widget.style
|
|
126
|
+
? {
|
|
127
|
+
fontSizePx: widget.style.fontSize ?? 12,
|
|
128
|
+
fontColor: widget.style.fontColor ?? '#000000',
|
|
129
|
+
fontFamily: widget.style.fontFamily,
|
|
130
|
+
strokeWidth: widget.style.strokeWidth,
|
|
131
|
+
strokeColor: widget.style.strokeColor,
|
|
132
|
+
}
|
|
133
|
+
: undefined,
|
|
134
|
+
},
|
|
135
|
+
]
|
|
136
|
+
: [];
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
key: field.key,
|
|
140
|
+
type: field.type,
|
|
141
|
+
value: normalizeExpression(field.value),
|
|
142
|
+
role: field.roleKey ?? field.role,
|
|
143
|
+
includeIf: extractExpressionString(field.includeIf ?? field.displayCondition),
|
|
144
|
+
widgets,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Transforms a map of named asset references (alias → "key@version") into
|
|
149
|
+
* an array of `{ key, version, alias }`. Used for image references, which
|
|
150
|
+
* are always plain string refs in YAML.
|
|
151
|
+
*/
|
|
152
|
+
function transformAssetObjectRefs(yamlRefs) {
|
|
153
|
+
if (!yamlRefs)
|
|
154
|
+
return undefined;
|
|
155
|
+
const results = [];
|
|
156
|
+
for (const [alias, ref] of Object.entries(yamlRefs)) {
|
|
157
|
+
const assetRef = typeof ref === 'string' ? ref : ref?.asset;
|
|
158
|
+
if (typeof assetRef === 'string') {
|
|
159
|
+
const [key, version] = assetRef.split('@');
|
|
160
|
+
results.push({ key, version, alias });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return results.length > 0 ? results : undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Transforms a map of partial references into an array of
|
|
167
|
+
* `{ key, version, alias, roleMap? }`. Partials support an object form in
|
|
168
|
+
* YAML that carries an optional `roleMap` alongside the asset reference:
|
|
169
|
+
*
|
|
170
|
+
* partials:
|
|
171
|
+
* buyer_sig:
|
|
172
|
+
* asset: signature_block@1.0.0
|
|
173
|
+
* roleMap: { signer: buyer }
|
|
174
|
+
*/
|
|
175
|
+
function transformPartialObjectRefs(yamlRefs) {
|
|
176
|
+
if (!yamlRefs)
|
|
177
|
+
return undefined;
|
|
178
|
+
const results = [];
|
|
179
|
+
for (const [alias, ref] of Object.entries(yamlRefs)) {
|
|
180
|
+
const assetRef = typeof ref === 'string' ? ref : ref?.asset;
|
|
181
|
+
if (typeof assetRef === 'string') {
|
|
182
|
+
const [key, version] = assetRef.split('@');
|
|
183
|
+
const roleMap = typeof ref === 'object' && ref?.roleMap ? ref.roleMap : undefined;
|
|
184
|
+
results.push({ key, version, alias, ...(roleMap ? { roleMap } : {}) });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return results.length > 0 ? results : undefined;
|
|
188
|
+
}
|
|
189
|
+
function transformEnvelopes(yamlEnvelopes) {
|
|
190
|
+
return yamlEnvelopes.map((env) => ({
|
|
191
|
+
key: env.key,
|
|
192
|
+
subject: normalizeExpression(env.subject) ?? env.name ?? env.key,
|
|
193
|
+
name: env.name,
|
|
194
|
+
resolutionMode: env.resolutionMode,
|
|
195
|
+
includeIf: extractExpressionString(env.includeIf),
|
|
196
|
+
documents: (env.documents ?? []).map((d) => {
|
|
197
|
+
const templateKey = d.templateKey ?? ((d.template ?? '').split('@')[0] || undefined);
|
|
198
|
+
const templateVersion = d.templateVersion ?? ((d.template ?? '').split('@')[1] || undefined);
|
|
199
|
+
const inputMap = Array.isArray(d.inputMap)
|
|
200
|
+
? d.inputMap
|
|
201
|
+
: d.inputMap && typeof d.inputMap === 'object'
|
|
202
|
+
? Object.entries(d.inputMap).map(([k, v]) => ({
|
|
203
|
+
templateInputKey: k,
|
|
204
|
+
blueprintInputKey: typeof v === 'string' ? extractBlueprintInputKey(v) : '',
|
|
205
|
+
}))
|
|
206
|
+
: undefined;
|
|
207
|
+
return {
|
|
208
|
+
key: d.key,
|
|
209
|
+
name: d.name ?? d.key,
|
|
210
|
+
templateKey,
|
|
211
|
+
templateVersion,
|
|
212
|
+
inputMap,
|
|
213
|
+
includeIf: d.includeIf,
|
|
214
|
+
iterator: d.iterator,
|
|
215
|
+
fileId: normalizeExpression(d.fileId),
|
|
216
|
+
};
|
|
217
|
+
}),
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
function transformParticipants(yamlParticipants) {
|
|
221
|
+
return yamlParticipants.map((p) => {
|
|
222
|
+
return {
|
|
223
|
+
key: p.key,
|
|
224
|
+
name: typeof p.name === 'string' ? p.name : p.key,
|
|
225
|
+
roleCategory: p.roleCategory,
|
|
226
|
+
participantName: normalizeExpression(p.name),
|
|
227
|
+
participantEmail: normalizeExpression(p.email),
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function transformCustomFields(yamlCustomFields) {
|
|
232
|
+
return yamlCustomFields.map((field) => ({
|
|
233
|
+
key: field.key,
|
|
234
|
+
name: field.name,
|
|
235
|
+
value: normalizeExpression(field.value) ?? field.value,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
function transformOrchestrationToTree(node) {
|
|
239
|
+
if (node.type === 'group') {
|
|
240
|
+
const step = {
|
|
241
|
+
key: node.key,
|
|
242
|
+
type: node.type,
|
|
243
|
+
execution: node.execution ?? node.executionMode ?? 'sequential',
|
|
244
|
+
completion: node.completion ??
|
|
245
|
+
node.completionRule ??
|
|
246
|
+
workflow_1.WorkflowStepCompletionRule.All,
|
|
247
|
+
children: (node.children ?? []).map((c) => transformOrchestrationToTree(c)),
|
|
248
|
+
};
|
|
249
|
+
if (node.name)
|
|
250
|
+
step.name = node.name;
|
|
251
|
+
if (node.includeIf)
|
|
252
|
+
step.includeIf = node.includeIf;
|
|
253
|
+
if (node.quorum ?? node.quorumCount)
|
|
254
|
+
step.quorum = node.quorum ?? node.quorumCount;
|
|
255
|
+
if (node.onComplete)
|
|
256
|
+
step.onComplete = transformOnComplete(node.onComplete);
|
|
257
|
+
return step;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const step = {
|
|
261
|
+
key: node.key,
|
|
262
|
+
type: node.type,
|
|
263
|
+
participantKey: node.participantKey ?? node.participant,
|
|
264
|
+
};
|
|
265
|
+
if (node.name)
|
|
266
|
+
step.name = node.name;
|
|
267
|
+
if (node.includeIf)
|
|
268
|
+
step.includeIf = node.includeIf;
|
|
269
|
+
if (node.action)
|
|
270
|
+
step.action = transformAction(node.action);
|
|
271
|
+
if (node.onComplete)
|
|
272
|
+
step.onComplete = transformOnComplete(node.onComplete);
|
|
273
|
+
return step;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function transformOnComplete(onComplete) {
|
|
277
|
+
const result = {};
|
|
278
|
+
if (onComplete.validate ?? onComplete.validateExpression) {
|
|
279
|
+
result.validate = onComplete.validate ?? onComplete.validateExpression;
|
|
280
|
+
}
|
|
281
|
+
if (onComplete.updates) {
|
|
282
|
+
result.updates = onComplete.updates;
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
function transformAction(action) {
|
|
287
|
+
return {
|
|
288
|
+
type: action.type,
|
|
289
|
+
envelopeKey: action.envelopeKey ?? action.envelope,
|
|
290
|
+
assignments: action.assignments?.map((a) => ({
|
|
291
|
+
documentKey: a.documentKey ?? a.document,
|
|
292
|
+
roleKey: a.roleKey ?? a.role,
|
|
293
|
+
})),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function transformJsonataParams(yamlParams) {
|
|
297
|
+
return yamlParams.map((p) => {
|
|
298
|
+
const type = p.type;
|
|
299
|
+
const result = { name: p.name, type };
|
|
300
|
+
if (type === jsonata_function_1.JsonataFunctionParamType.Array && p.itemType) {
|
|
301
|
+
result.itemType = p.itemType;
|
|
302
|
+
}
|
|
303
|
+
const allowsSchema = type === jsonata_function_1.JsonataFunctionParamType.Object ||
|
|
304
|
+
(type === jsonata_function_1.JsonataFunctionParamType.Array &&
|
|
305
|
+
result.itemType === jsonata_function_1.JsonataFunctionItemType.Object);
|
|
306
|
+
if (allowsSchema) {
|
|
307
|
+
if (p.schemaKey) {
|
|
308
|
+
result.schemaKey = p.schemaKey;
|
|
309
|
+
result.schemaVersion = p.schemaVersion;
|
|
310
|
+
}
|
|
311
|
+
else if (p.schema) {
|
|
312
|
+
const [schemaKey, schemaVersion] = p.schema.split('@');
|
|
313
|
+
result.schemaKey = schemaKey;
|
|
314
|
+
result.schemaVersion = schemaVersion;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return result;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function transformJsonataReturnType(yamlReturnType) {
|
|
321
|
+
const type = (yamlReturnType?.type ??
|
|
322
|
+
jsonata_function_1.JsonataFunctionParamType.String);
|
|
323
|
+
const result = { type };
|
|
324
|
+
if (type === jsonata_function_1.JsonataFunctionParamType.Array && yamlReturnType?.itemType) {
|
|
325
|
+
result.itemType = yamlReturnType.itemType;
|
|
326
|
+
}
|
|
327
|
+
const allowsSchema = type === jsonata_function_1.JsonataFunctionParamType.Object ||
|
|
328
|
+
(type === jsonata_function_1.JsonataFunctionParamType.Array &&
|
|
329
|
+
result.itemType === jsonata_function_1.JsonataFunctionItemType.Object);
|
|
330
|
+
if (allowsSchema) {
|
|
331
|
+
if (yamlReturnType?.schemaKey) {
|
|
332
|
+
result.schemaKey = yamlReturnType.schemaKey;
|
|
333
|
+
result.schemaVersion = yamlReturnType.schemaVersion;
|
|
334
|
+
}
|
|
335
|
+
else if (yamlReturnType?.schema) {
|
|
336
|
+
const [schemaKey, schemaVersion] = yamlReturnType.schema.split('@');
|
|
337
|
+
result.schemaKey = schemaKey;
|
|
338
|
+
result.schemaVersion = schemaVersion;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
function buildHtmlConfigRefs(spec) {
|
|
344
|
+
if (!spec)
|
|
345
|
+
return undefined;
|
|
346
|
+
const refs = {};
|
|
347
|
+
let hasRefs = false;
|
|
348
|
+
const partials = transformPartialObjectRefs(spec.partials);
|
|
349
|
+
if (partials) {
|
|
350
|
+
refs.partials = partials;
|
|
351
|
+
hasRefs = true;
|
|
352
|
+
}
|
|
353
|
+
if (spec.styles && Array.isArray(spec.styles)) {
|
|
354
|
+
const styles = spec.styles
|
|
355
|
+
.filter((s) => typeof s === 'string')
|
|
356
|
+
.map((s) => {
|
|
357
|
+
const [key, version] = s.split('@');
|
|
358
|
+
return { key, version };
|
|
359
|
+
});
|
|
360
|
+
if (styles.length > 0) {
|
|
361
|
+
refs.styles = styles;
|
|
362
|
+
hasRefs = true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const images = transformAssetObjectRefs(spec.images);
|
|
366
|
+
if (images) {
|
|
367
|
+
refs.images = images;
|
|
368
|
+
hasRefs = true;
|
|
369
|
+
}
|
|
370
|
+
const viewModelSchemaRef = spec.data?.schema;
|
|
371
|
+
if (viewModelSchemaRef) {
|
|
372
|
+
const [key, version] = viewModelSchemaRef.split('@');
|
|
373
|
+
refs.data = { schemaKey: key, schemaVersion: version };
|
|
374
|
+
hasRefs = true;
|
|
375
|
+
}
|
|
376
|
+
if (spec.pdfSettings) {
|
|
377
|
+
refs.pdfSettings = spec.pdfSettings;
|
|
378
|
+
hasRefs = true;
|
|
379
|
+
}
|
|
380
|
+
return hasRefs ? refs : undefined;
|
|
381
|
+
}
|
|
382
|
+
// ─── Per-Kind Spec Converters ───────────────────────────────────────
|
|
383
|
+
function convertAssetYamlSpec(spec) {
|
|
384
|
+
const converted = { ...spec };
|
|
385
|
+
// Build htmlConfig from top-level CLI fields
|
|
386
|
+
const htmlConfig = buildHtmlConfigRefs(spec);
|
|
387
|
+
if (htmlConfig) {
|
|
388
|
+
converted.htmlConfig = htmlConfig;
|
|
389
|
+
}
|
|
390
|
+
// Remove fields consumed by htmlConfig
|
|
391
|
+
delete converted.partials;
|
|
392
|
+
delete converted.styles;
|
|
393
|
+
delete converted.images;
|
|
394
|
+
delete converted.pdfSettings;
|
|
395
|
+
if (converted.data?.schema) {
|
|
396
|
+
delete converted.data;
|
|
397
|
+
}
|
|
398
|
+
// Remove file path (not applicable for API creation)
|
|
399
|
+
delete converted.file;
|
|
400
|
+
return converted;
|
|
401
|
+
}
|
|
402
|
+
function convertTemplateYamlSpec(spec) {
|
|
403
|
+
const contentKey = spec.contentKey ?? (spec.content ?? '').split('@')[0] ?? '';
|
|
404
|
+
const contentVersion = spec.contentVersion ?? (spec.content ?? '').split('@')[1] ?? '';
|
|
405
|
+
const inputs = transformExpressionInputs(spec.inputs ?? []);
|
|
406
|
+
const roles = (spec.roles ?? []).map(transformRole);
|
|
407
|
+
const fields = (spec.fields ?? []).map(transformField);
|
|
408
|
+
const data = spec.data?.transform
|
|
409
|
+
? { transform: spec.data.transform }
|
|
410
|
+
: undefined;
|
|
411
|
+
const functions = normalizeYamlFunctionsBlock(spec.functions);
|
|
412
|
+
return {
|
|
413
|
+
type: spec.type ?? 'pdf',
|
|
414
|
+
contentKey,
|
|
415
|
+
contentVersion,
|
|
416
|
+
data,
|
|
417
|
+
fields,
|
|
418
|
+
inputs,
|
|
419
|
+
roles,
|
|
420
|
+
functions,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function convertBlueprintYamlSpec(spec) {
|
|
424
|
+
const inputs = transformInputs(spec.inputs ?? []);
|
|
425
|
+
const envelopes = transformEnvelopes(spec.envelopes ?? []);
|
|
426
|
+
const participants = transformParticipants(spec.participants ?? []);
|
|
427
|
+
const customFields = transformCustomFields(spec.customFields ?? []);
|
|
428
|
+
const orchestration = spec.orchestration
|
|
429
|
+
? transformOrchestrationToTree(spec.orchestration)
|
|
430
|
+
: undefined;
|
|
431
|
+
const functions = normalizeYamlFunctionsBlock(spec.functions);
|
|
432
|
+
return {
|
|
433
|
+
envelopes,
|
|
434
|
+
participants,
|
|
435
|
+
inputs,
|
|
436
|
+
customFields,
|
|
437
|
+
orchestration,
|
|
438
|
+
functions,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Normalize a YAML `functions` block (object map or array form) into the API
|
|
443
|
+
* shape `{ alias, functionKey, functionVersion }[]`.
|
|
444
|
+
*
|
|
445
|
+
* Supported shapes:
|
|
446
|
+
* - Object map: `{ money: "format_currency@1.0.0" }` (key is alias)
|
|
447
|
+
* - Array of strings: `["format_currency@1.0.0"]` (alias = functionKey)
|
|
448
|
+
*/
|
|
449
|
+
function normalizeYamlFunctionsBlock(fns) {
|
|
450
|
+
if (!fns)
|
|
451
|
+
return undefined;
|
|
452
|
+
if (Array.isArray(fns)) {
|
|
453
|
+
return fns.flatMap((entry) => {
|
|
454
|
+
if (typeof entry !== 'string')
|
|
455
|
+
return [];
|
|
456
|
+
const [functionKey, functionVersion] = entry.split('@');
|
|
457
|
+
// No alias for array form — function is callable as $functionKey(...)
|
|
458
|
+
return [
|
|
459
|
+
{ functionKey, functionVersion: functionVersion || base_1.DRAFT_VERSION },
|
|
460
|
+
];
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
if (typeof fns === 'object') {
|
|
464
|
+
return Object.entries(fns).flatMap(([alias, ref]) => {
|
|
465
|
+
if (typeof ref !== 'string')
|
|
466
|
+
return [];
|
|
467
|
+
const [functionKey, functionVersion] = ref.split('@');
|
|
468
|
+
return [
|
|
469
|
+
{
|
|
470
|
+
alias,
|
|
471
|
+
functionKey,
|
|
472
|
+
functionVersion: functionVersion || base_1.DRAFT_VERSION,
|
|
473
|
+
},
|
|
474
|
+
];
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
function convertFunctionYamlSpec(spec) {
|
|
480
|
+
const params = transformJsonataParams(spec.params ?? []);
|
|
481
|
+
const returnType = transformJsonataReturnType(spec.returnType);
|
|
482
|
+
return {
|
|
483
|
+
params: params.length > 0 ? params : undefined,
|
|
484
|
+
returnType,
|
|
485
|
+
body: spec.body ?? '',
|
|
486
|
+
...(spec.functions && { functions: spec.functions }),
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
// ─── API Format Detection ───────────────────────────────────────────
|
|
490
|
+
/**
|
|
491
|
+
* Detect whether a spec is already in API format (vs CLI YAML format).
|
|
492
|
+
* API format uses split key/version fields (e.g. templateKey + templateVersion),
|
|
493
|
+
* while YAML format uses combined refs (e.g. template: "key@version").
|
|
494
|
+
*/
|
|
495
|
+
function isApiFormat(kind, spec) {
|
|
496
|
+
switch (kind) {
|
|
497
|
+
case resource_edge_1.ResourceKind.Blueprint:
|
|
498
|
+
// Always convert — AI generates mixed CLI/API formats
|
|
499
|
+
return false;
|
|
500
|
+
case resource_edge_1.ResourceKind.Template:
|
|
501
|
+
// Always convert — AI generates mixed CLI/API formats
|
|
502
|
+
return false;
|
|
503
|
+
case resource_edge_1.ResourceKind.Asset:
|
|
504
|
+
return spec.htmlConfig !== undefined;
|
|
505
|
+
case resource_edge_1.ResourceKind.JsonataFunction:
|
|
506
|
+
// Always convert — YAML uses combined 'schema' ref that needs splitting into schemaKey/schemaVersion
|
|
507
|
+
return false;
|
|
508
|
+
default:
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
// ─── Main Entry Points ──────────────────────────────────────────────
|
|
513
|
+
/**
|
|
514
|
+
* Convert a YAML spec to API format based on resource kind.
|
|
515
|
+
* If the spec is already in API format, returns it as-is.
|
|
516
|
+
*/
|
|
517
|
+
function convertYamlSpec(kind, spec) {
|
|
518
|
+
if (isApiFormat(kind, spec)) {
|
|
519
|
+
return { ...spec };
|
|
520
|
+
}
|
|
521
|
+
switch (kind) {
|
|
522
|
+
case resource_edge_1.ResourceKind.Schema:
|
|
523
|
+
return { ...spec };
|
|
524
|
+
case resource_edge_1.ResourceKind.Asset:
|
|
525
|
+
return convertAssetYamlSpec(spec);
|
|
526
|
+
case resource_edge_1.ResourceKind.Template:
|
|
527
|
+
return convertTemplateYamlSpec(spec);
|
|
528
|
+
case resource_edge_1.ResourceKind.Blueprint:
|
|
529
|
+
return convertBlueprintYamlSpec(spec);
|
|
530
|
+
case resource_edge_1.ResourceKind.JsonataFunction:
|
|
531
|
+
return convertFunctionYamlSpec(spec);
|
|
532
|
+
default:
|
|
533
|
+
return { ...spec };
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function displayNameToResourceKind(display) {
|
|
537
|
+
switch (display) {
|
|
538
|
+
case 'Schema':
|
|
539
|
+
case resource_edge_1.ResourceKind.Schema:
|
|
540
|
+
return resource_edge_1.ResourceKind.Schema;
|
|
541
|
+
case 'Asset':
|
|
542
|
+
case resource_edge_1.ResourceKind.Asset:
|
|
543
|
+
return resource_edge_1.ResourceKind.Asset;
|
|
544
|
+
case 'Template':
|
|
545
|
+
case resource_edge_1.ResourceKind.Template:
|
|
546
|
+
return resource_edge_1.ResourceKind.Template;
|
|
547
|
+
case 'JsonataFunction':
|
|
548
|
+
case resource_edge_1.ResourceKind.JsonataFunction:
|
|
549
|
+
return resource_edge_1.ResourceKind.JsonataFunction;
|
|
550
|
+
case 'Blueprint':
|
|
551
|
+
case resource_edge_1.ResourceKind.Blueprint:
|
|
552
|
+
return resource_edge_1.ResourceKind.Blueprint;
|
|
553
|
+
default:
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function resourceKindToDisplayName(kind) {
|
|
558
|
+
switch (kind) {
|
|
559
|
+
case resource_edge_1.ResourceKind.Schema:
|
|
560
|
+
return 'Schema';
|
|
561
|
+
case resource_edge_1.ResourceKind.Asset:
|
|
562
|
+
return 'Asset';
|
|
563
|
+
case resource_edge_1.ResourceKind.Template:
|
|
564
|
+
return 'Template';
|
|
565
|
+
case resource_edge_1.ResourceKind.JsonataFunction:
|
|
566
|
+
return 'JsonataFunction';
|
|
567
|
+
case resource_edge_1.ResourceKind.Blueprint:
|
|
568
|
+
return 'Blueprint';
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
// ─── API → YAML Object Converters ──────────────────────────────────
|
|
572
|
+
//
|
|
573
|
+
// These convert API-format resources (as stored in MasterResourceStore)
|
|
574
|
+
// into clean YAML-friendly plain objects. The caller stringifies with
|
|
575
|
+
// `yaml.stringify(result, { lineWidth: 0 })`.
|
|
576
|
+
function formatMetadataForYaml(metadata) {
|
|
577
|
+
return {
|
|
578
|
+
key: metadata?.key || '',
|
|
579
|
+
version: metadata?.version || '',
|
|
580
|
+
name: metadata?.name || '',
|
|
581
|
+
...(metadata?.description && { description: metadata.description }),
|
|
582
|
+
...(metadata?.labels &&
|
|
583
|
+
Object.keys(metadata.labels).length && {
|
|
584
|
+
labels: metadata.labels,
|
|
585
|
+
}),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function schemaToYamlObject(metadata, spec) {
|
|
589
|
+
const parsedDefinition = (() => {
|
|
590
|
+
if (!spec?.schemaDefinition)
|
|
591
|
+
return undefined;
|
|
592
|
+
if (typeof spec.schemaDefinition === 'object')
|
|
593
|
+
return spec.schemaDefinition;
|
|
594
|
+
try {
|
|
595
|
+
return JSON.parse(spec.schemaDefinition);
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
return undefined;
|
|
599
|
+
}
|
|
600
|
+
})();
|
|
601
|
+
return {
|
|
602
|
+
apiVersion: 'signstack/v1beta2',
|
|
603
|
+
kind: 'Schema',
|
|
604
|
+
metadata: formatMetadataForYaml(metadata),
|
|
605
|
+
spec: {
|
|
606
|
+
jsonSchemaDraft: spec?.jsonSchemaDraft ?? '2020-12',
|
|
607
|
+
...(parsedDefinition && { schemaDefinition: parsedDefinition }),
|
|
608
|
+
},
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function assetToYamlObject(metadata, spec) {
|
|
612
|
+
const assetType = spec?.type ?? base_1.AssetType.Html;
|
|
613
|
+
const content = spec?.content;
|
|
614
|
+
const yamlSpec = { type: assetType };
|
|
615
|
+
if (assetType !== base_1.AssetType.Image && assetType !== base_1.AssetType.Pdf && content) {
|
|
616
|
+
yamlSpec.content = content;
|
|
617
|
+
}
|
|
618
|
+
if (spec?.fileId)
|
|
619
|
+
yamlSpec.fileId = spec.fileId;
|
|
620
|
+
// htmlConfig → YAML partials/images/styles/data/pdfSettings
|
|
621
|
+
const config = spec?.htmlConfig;
|
|
622
|
+
if (config) {
|
|
623
|
+
if (config.partials?.length) {
|
|
624
|
+
yamlSpec.partials = {};
|
|
625
|
+
for (const p of config.partials) {
|
|
626
|
+
const assetRef = toRef(p.key, p.version);
|
|
627
|
+
if (p.roleMap && Object.keys(p.roleMap).length > 0) {
|
|
628
|
+
yamlSpec.partials[p.alias] = {
|
|
629
|
+
asset: assetRef,
|
|
630
|
+
roleMap: p.roleMap,
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
yamlSpec.partials[p.alias] = assetRef;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (config.images?.length) {
|
|
639
|
+
yamlSpec.images = {};
|
|
640
|
+
for (const img of config.images) {
|
|
641
|
+
yamlSpec.images[img.alias] = toRef(img.key, img.version);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (config.styles?.length) {
|
|
645
|
+
yamlSpec.styles = config.styles.map((s) => toRef(s.key, s.version));
|
|
646
|
+
}
|
|
647
|
+
if (config.data?.schemaKey) {
|
|
648
|
+
yamlSpec.data = {
|
|
649
|
+
schema: toRef(config.data.schemaKey, config.data.schemaVersion),
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
if (config.pdfSettings) {
|
|
653
|
+
yamlSpec.pdfSettings = config.pdfSettings;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return {
|
|
657
|
+
apiVersion: 'signstack/v1beta2',
|
|
658
|
+
kind: 'Asset',
|
|
659
|
+
metadata: formatMetadataForYaml(metadata),
|
|
660
|
+
spec: yamlSpec,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function functionToYamlObject(metadata, spec) {
|
|
664
|
+
const params = (spec?.params ?? [])
|
|
665
|
+
.filter((p) => p.name && p.name.trim())
|
|
666
|
+
.map((p) => {
|
|
667
|
+
const result = {
|
|
668
|
+
name: p.name,
|
|
669
|
+
type: p.type,
|
|
670
|
+
};
|
|
671
|
+
if (p.type === jsonata_function_1.JsonataFunctionParamType.Array && p.itemType) {
|
|
672
|
+
result.itemType = p.itemType;
|
|
673
|
+
}
|
|
674
|
+
const allowsSchema = p.type === jsonata_function_1.JsonataFunctionParamType.Object ||
|
|
675
|
+
(p.type === jsonata_function_1.JsonataFunctionParamType.Array &&
|
|
676
|
+
p.itemType === jsonata_function_1.JsonataFunctionItemType.Object);
|
|
677
|
+
if (allowsSchema) {
|
|
678
|
+
const schemaRef = toRef(p.schemaKey, p.schemaVersion);
|
|
679
|
+
if (schemaRef)
|
|
680
|
+
result.schema = schemaRef;
|
|
681
|
+
}
|
|
682
|
+
return result;
|
|
683
|
+
});
|
|
684
|
+
const returnType = spec?.returnType ?? { type: 'string' };
|
|
685
|
+
const yamlReturnType = { type: returnType.type };
|
|
686
|
+
if (returnType.type === jsonata_function_1.JsonataFunctionParamType.Array &&
|
|
687
|
+
returnType.itemType) {
|
|
688
|
+
yamlReturnType.itemType = returnType.itemType;
|
|
689
|
+
}
|
|
690
|
+
const rtAllowsSchema = returnType.type === jsonata_function_1.JsonataFunctionParamType.Object ||
|
|
691
|
+
(returnType.type === jsonata_function_1.JsonataFunctionParamType.Array &&
|
|
692
|
+
returnType.itemType === jsonata_function_1.JsonataFunctionItemType.Object);
|
|
693
|
+
if (rtAllowsSchema) {
|
|
694
|
+
const rtSchema = toRef(returnType.schemaKey, returnType.schemaVersion);
|
|
695
|
+
if (rtSchema)
|
|
696
|
+
yamlReturnType.schema = rtSchema;
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
apiVersion: 'signstack/v1beta2',
|
|
700
|
+
kind: 'JsonataFunction',
|
|
701
|
+
metadata: formatMetadataForYaml(metadata),
|
|
702
|
+
spec: {
|
|
703
|
+
...(params.length > 0 && { params }),
|
|
704
|
+
returnType: yamlReturnType,
|
|
705
|
+
...(spec?.body && { body: spec.body }),
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Convert an API-format resource into a YAML-friendly plain object.
|
|
711
|
+
* For resource kinds without special formatting (Template, Blueprint),
|
|
712
|
+
* returns a generic `{ kind, metadata, spec }` structure.
|
|
713
|
+
*/
|
|
714
|
+
function convertResourceToYamlObject(kind, metadata, spec) {
|
|
715
|
+
switch (kind) {
|
|
716
|
+
case resource_edge_1.ResourceKind.Schema:
|
|
717
|
+
return schemaToYamlObject(metadata, spec);
|
|
718
|
+
case resource_edge_1.ResourceKind.Asset:
|
|
719
|
+
return assetToYamlObject(metadata, spec);
|
|
720
|
+
case resource_edge_1.ResourceKind.JsonataFunction:
|
|
721
|
+
return functionToYamlObject(metadata, spec);
|
|
722
|
+
case resource_edge_1.ResourceKind.Blueprint:
|
|
723
|
+
return blueprintToYamlObject(metadata, spec);
|
|
724
|
+
case resource_edge_1.ResourceKind.Template:
|
|
725
|
+
return templateToYamlObject(metadata, spec);
|
|
726
|
+
default:
|
|
727
|
+
return {
|
|
728
|
+
kind: resourceKindToDisplayName(kind),
|
|
729
|
+
metadata: formatMetadataForYaml(metadata),
|
|
730
|
+
spec,
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Convert an API-format resource into a YAML string.
|
|
736
|
+
* Convenience wrapper around convertResourceToYamlObject + yamlStringify.
|
|
737
|
+
*/
|
|
738
|
+
function resourceToYaml(kind, metadata, spec) {
|
|
739
|
+
try {
|
|
740
|
+
return (0, yaml_1.stringify)(convertResourceToYamlObject(kind, metadata, spec), {
|
|
741
|
+
lineWidth: 0,
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
catch (e) {
|
|
745
|
+
console.error('Failed to stringify resource to YAML:', e);
|
|
746
|
+
return '';
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
// ── Helper: combine key@version ──
|
|
750
|
+
function toRef(key, version) {
|
|
751
|
+
if (!key)
|
|
752
|
+
return undefined;
|
|
753
|
+
return version ? `${key}@${version}` : key;
|
|
754
|
+
}
|
|
755
|
+
function passthroughExpression(value) {
|
|
756
|
+
if (value == null)
|
|
757
|
+
return undefined;
|
|
758
|
+
return value;
|
|
759
|
+
}
|
|
760
|
+
// ── Blueprint API → YAML ──
|
|
761
|
+
function blueprintToYamlObject(metadata, spec) {
|
|
762
|
+
const yamlSpec = {};
|
|
763
|
+
// inputs: schemaKey/schemaVersion → schema: key@version
|
|
764
|
+
if (spec?.inputs?.length) {
|
|
765
|
+
yamlSpec.inputs = spec.inputs.map((input) => {
|
|
766
|
+
const result = { key: input.key };
|
|
767
|
+
if (input.name)
|
|
768
|
+
result.name = input.name;
|
|
769
|
+
result.schema = toRef(input.schemaKey, input.schemaVersion);
|
|
770
|
+
if (input.required !== undefined)
|
|
771
|
+
result.required = passthroughExpression(input.required);
|
|
772
|
+
return result;
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
// functions: emit object-map only when at least one entry has a distinct alias
|
|
776
|
+
if (spec?.functions?.length) {
|
|
777
|
+
const hasDistinctAlias = spec.functions.some((fn) => fn.alias);
|
|
778
|
+
if (hasDistinctAlias) {
|
|
779
|
+
yamlSpec.functions = {};
|
|
780
|
+
for (const fn of spec.functions) {
|
|
781
|
+
yamlSpec.functions[fn.alias ?? fn.functionKey] = toRef(fn.functionKey, fn.functionVersion);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
yamlSpec.functions = spec.functions.map((fn) => toRef(fn.functionKey, fn.functionVersion));
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
// participants: participantName/participantEmail → name/email exprs
|
|
789
|
+
if (spec?.participants?.length) {
|
|
790
|
+
yamlSpec.participants = spec.participants.map((p) => {
|
|
791
|
+
const result = { key: p.key };
|
|
792
|
+
if (p.participantName) {
|
|
793
|
+
result.name = passthroughExpression(p.participantName);
|
|
794
|
+
}
|
|
795
|
+
else if (p.name) {
|
|
796
|
+
result.name = p.name;
|
|
797
|
+
}
|
|
798
|
+
if (p.participantEmail) {
|
|
799
|
+
result.email = passthroughExpression(p.participantEmail);
|
|
800
|
+
}
|
|
801
|
+
if (p.roleCategory)
|
|
802
|
+
result.roleCategory = p.roleCategory;
|
|
803
|
+
return result;
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
// envelopes: templateKey/templateVersion → template: key@version
|
|
807
|
+
if (spec?.envelopes?.length) {
|
|
808
|
+
yamlSpec.envelopes = spec.envelopes.map((env) => {
|
|
809
|
+
const yamlEnv = { key: env.key };
|
|
810
|
+
if (env.name)
|
|
811
|
+
yamlEnv.name = env.name;
|
|
812
|
+
if (env.subject)
|
|
813
|
+
yamlEnv.subject = passthroughExpression(env.subject);
|
|
814
|
+
if (env.includeIf)
|
|
815
|
+
yamlEnv.includeIf = env.includeIf;
|
|
816
|
+
if (env.documents?.length) {
|
|
817
|
+
yamlEnv.documents = env.documents.map((doc) => {
|
|
818
|
+
const yamlDoc = { key: doc.key };
|
|
819
|
+
if (doc.name)
|
|
820
|
+
yamlDoc.name = doc.name;
|
|
821
|
+
yamlDoc.template = toRef(doc.templateKey, doc.templateVersion);
|
|
822
|
+
if (doc.inputMap?.length) {
|
|
823
|
+
yamlDoc.inputMap = {};
|
|
824
|
+
for (const m of doc.inputMap) {
|
|
825
|
+
yamlDoc.inputMap[m.templateInputKey] = m.blueprintInputKey
|
|
826
|
+
? `$.${m.blueprintInputKey}`
|
|
827
|
+
: m.blueprintInputKey;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
if (doc.includeIf)
|
|
831
|
+
yamlDoc.includeIf = doc.includeIf;
|
|
832
|
+
if (doc.iterator)
|
|
833
|
+
yamlDoc.iterator = doc.iterator;
|
|
834
|
+
if (doc.fileId)
|
|
835
|
+
yamlDoc.fileId = passthroughExpression(doc.fileId);
|
|
836
|
+
return yamlDoc;
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
return yamlEnv;
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
// customFields: pass through expression value
|
|
843
|
+
if (spec?.customFields?.length) {
|
|
844
|
+
yamlSpec.customFields = spec.customFields.map((cf) => ({
|
|
845
|
+
...cf,
|
|
846
|
+
value: passthroughExpression(cf.value),
|
|
847
|
+
}));
|
|
848
|
+
}
|
|
849
|
+
// orchestration: convert step tree
|
|
850
|
+
if (spec?.orchestration) {
|
|
851
|
+
yamlSpec.orchestration = stepToYaml(spec.orchestration);
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
apiVersion: 'signstack/v1beta2',
|
|
855
|
+
kind: 'Blueprint',
|
|
856
|
+
metadata: formatMetadataForYaml(metadata),
|
|
857
|
+
spec: yamlSpec,
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
function stepToYaml(step) {
|
|
861
|
+
const result = { key: step.key, type: step.type };
|
|
862
|
+
if (step.name)
|
|
863
|
+
result.name = step.name;
|
|
864
|
+
if (step.includeIf)
|
|
865
|
+
result.includeIf = step.includeIf;
|
|
866
|
+
if (step.type === 'group') {
|
|
867
|
+
result.execution = step.execution ?? 'sequential';
|
|
868
|
+
if (step.completion && step.completion !== 'all') {
|
|
869
|
+
result.completion = step.completion;
|
|
870
|
+
}
|
|
871
|
+
if (step.quorum)
|
|
872
|
+
result.quorum = step.quorum;
|
|
873
|
+
if (step.children?.length) {
|
|
874
|
+
result.children = step.children.map(stepToYaml);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
else {
|
|
878
|
+
result.participant = step.participantKey;
|
|
879
|
+
if (step.action) {
|
|
880
|
+
result.action = {
|
|
881
|
+
type: step.action.type,
|
|
882
|
+
envelope: step.action.envelopeKey,
|
|
883
|
+
...(step.action.assignments?.length && {
|
|
884
|
+
assignments: step.action.assignments.map((a) => ({
|
|
885
|
+
document: a.documentKey,
|
|
886
|
+
role: a.roleKey,
|
|
887
|
+
})),
|
|
888
|
+
}),
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (step.onComplete)
|
|
893
|
+
result.onComplete = step.onComplete;
|
|
894
|
+
return result;
|
|
895
|
+
}
|
|
896
|
+
// ── Template API → YAML ──
|
|
897
|
+
function templateToYamlObject(metadata, spec) {
|
|
898
|
+
const yamlSpec = {};
|
|
899
|
+
if (spec?.type)
|
|
900
|
+
yamlSpec.type = spec.type;
|
|
901
|
+
// content: contentKey/contentVersion → content: key@version
|
|
902
|
+
const contentRef = toRef(spec?.contentKey, spec?.contentVersion);
|
|
903
|
+
if (contentRef)
|
|
904
|
+
yamlSpec.content = contentRef;
|
|
905
|
+
// inputs: schemaKey/schemaVersion → schema: key@version
|
|
906
|
+
if (spec?.inputs?.length) {
|
|
907
|
+
yamlSpec.inputs = spec.inputs.map((input) => {
|
|
908
|
+
const result = { key: input.key };
|
|
909
|
+
if (input.name)
|
|
910
|
+
result.name = input.name;
|
|
911
|
+
result.schema = toRef(input.schemaKey, input.schemaVersion);
|
|
912
|
+
if (input.required !== undefined)
|
|
913
|
+
result.required = passthroughExpression(input.required);
|
|
914
|
+
return result;
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
// functions: emit object-map only when at least one entry has a distinct alias
|
|
918
|
+
if (spec?.functions?.length) {
|
|
919
|
+
const hasDistinctAlias = spec.functions.some((fn) => fn.alias);
|
|
920
|
+
if (hasDistinctAlias) {
|
|
921
|
+
yamlSpec.functions = {};
|
|
922
|
+
for (const fn of spec.functions) {
|
|
923
|
+
yamlSpec.functions[fn.alias ?? fn.functionKey] = toRef(fn.functionKey, fn.functionVersion);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
yamlSpec.functions = spec.functions.map((fn) => toRef(fn.functionKey, fn.functionVersion));
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
// roles
|
|
931
|
+
if (spec?.roles?.length) {
|
|
932
|
+
yamlSpec.roles = spec.roles.map((role) => {
|
|
933
|
+
const result = { key: role.key };
|
|
934
|
+
if (role.name)
|
|
935
|
+
result.name = role.name;
|
|
936
|
+
if (role.output) {
|
|
937
|
+
result.output = { ...role.output };
|
|
938
|
+
result.output.schema = toRef(role.output.schemaKey, role.output.schemaVersion);
|
|
939
|
+
delete result.output.schemaKey;
|
|
940
|
+
delete result.output.schemaVersion;
|
|
941
|
+
}
|
|
942
|
+
return result;
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
// fields: convert API widgets array back to singular widget object
|
|
946
|
+
if (spec?.fields?.length) {
|
|
947
|
+
yamlSpec.fields = spec.fields.map((field) => {
|
|
948
|
+
const result = { key: field.key, type: field.type };
|
|
949
|
+
if (field.role)
|
|
950
|
+
result.role = field.role;
|
|
951
|
+
else if (field.roleKey)
|
|
952
|
+
result.role = field.roleKey;
|
|
953
|
+
if (field.value !== undefined)
|
|
954
|
+
result.value = passthroughExpression(field.value);
|
|
955
|
+
if (field.includeIf)
|
|
956
|
+
result.includeIf = field.includeIf;
|
|
957
|
+
// Convert widgets array → singular widget object for YAML schema
|
|
958
|
+
const widgets = field.widgets;
|
|
959
|
+
if (Array.isArray(widgets) && widgets.length > 0) {
|
|
960
|
+
const w = widgets[0];
|
|
961
|
+
result.widget = {
|
|
962
|
+
page: w.position?.pageNumber ?? w.page ?? 1,
|
|
963
|
+
x: w.position?.x ?? w.x ?? 0,
|
|
964
|
+
y: w.position?.y ?? w.y ?? 0,
|
|
965
|
+
width: w.dimensions?.width ?? w.width ?? 200,
|
|
966
|
+
height: w.dimensions?.height ?? w.height ?? 20,
|
|
967
|
+
...(w.rotationDegree !== undefined &&
|
|
968
|
+
w.rotationDegree !== 0 && { rotation: w.rotationDegree }),
|
|
969
|
+
...(w.style || w.dimensions?.style
|
|
970
|
+
? {
|
|
971
|
+
style: {
|
|
972
|
+
...(w.style?.fontSizePx && { fontSize: w.style.fontSizePx }),
|
|
973
|
+
...(w.style?.fontColor && { fontColor: w.style.fontColor }),
|
|
974
|
+
...(w.style?.fontFamily && {
|
|
975
|
+
fontFamily: w.style.fontFamily,
|
|
976
|
+
}),
|
|
977
|
+
},
|
|
978
|
+
}
|
|
979
|
+
: {}),
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
else if (field.widget) {
|
|
983
|
+
result.widget = field.widget;
|
|
984
|
+
}
|
|
985
|
+
return result;
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
// data (HTML data config)
|
|
989
|
+
if (spec?.data)
|
|
990
|
+
yamlSpec.data = spec.data;
|
|
991
|
+
return {
|
|
992
|
+
apiVersion: 'signstack/v1beta2',
|
|
993
|
+
kind: 'Template',
|
|
994
|
+
metadata: formatMetadataForYaml(metadata),
|
|
995
|
+
spec: yamlSpec,
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
//# sourceMappingURL=yaml-spec-converter.js.map
|