openxiangda 1.0.264 → 2.0.0-alpha.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/README.md +11 -666
- package/bin/run.js +11 -0
- package/dist/browser/AuthoritativeSelector.d.ts +37 -0
- package/dist/browser/AuthoritativeSelector.d.ts.map +1 -0
- package/dist/browser/AuthoritativeSelector.js +357 -0
- package/dist/browser/AuthoritativeSelector.js.map +1 -0
- package/dist/browser/FilePreviewPage.d.ts +2 -0
- package/dist/browser/FilePreviewPage.d.ts.map +1 -0
- package/dist/browser/FilePreviewPage.js +191 -0
- package/dist/browser/FilePreviewPage.js.map +1 -0
- package/dist/browser/Shell.d.ts +6 -0
- package/dist/browser/Shell.d.ts.map +1 -0
- package/dist/browser/Shell.js +198 -0
- package/dist/browser/Shell.js.map +1 -0
- package/dist/browser/appearance.d.ts +12 -0
- package/dist/browser/appearance.d.ts.map +1 -0
- package/dist/browser/appearance.js +100 -0
- package/dist/browser/appearance.js.map +1 -0
- package/dist/browser/application.d.ts +8 -0
- package/dist/browser/application.d.ts.map +1 -0
- package/dist/browser/application.js +42 -0
- package/dist/browser/application.js.map +1 -0
- package/dist/browser/components/platform-fields/AddressField.d.ts +12 -0
- package/dist/browser/components/platform-fields/AddressField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/AddressField.js +179 -0
- package/dist/browser/components/platform-fields/AddressField.js.map +1 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts +9 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.js +164 -0
- package/dist/browser/components/platform-fields/AttachmentFileList.js.map +1 -0
- package/dist/browser/components/platform-fields/CascadeField.d.ts +13 -0
- package/dist/browser/components/platform-fields/CascadeField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/CascadeField.js +14 -0
- package/dist/browser/components/platform-fields/CascadeField.js.map +1 -0
- package/dist/browser/components/platform-fields/DateTimeField.d.ts +16 -0
- package/dist/browser/components/platform-fields/DateTimeField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/DateTimeField.js +51 -0
- package/dist/browser/components/platform-fields/DateTimeField.js.map +1 -0
- package/dist/browser/components/platform-fields/JsonField.d.ts +11 -0
- package/dist/browser/components/platform-fields/JsonField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/JsonField.js +40 -0
- package/dist/browser/components/platform-fields/JsonField.js.map +1 -0
- package/dist/browser/components/platform-fields/LocationField.d.ts +11 -0
- package/dist/browser/components/platform-fields/LocationField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/LocationField.js +73 -0
- package/dist/browser/components/platform-fields/LocationField.js.map +1 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.d.ts +12 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.js +269 -0
- package/dist/browser/components/platform-fields/PlatformDirectoryPicker.js.map +1 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts +12 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.js +22 -0
- package/dist/browser/components/platform-fields/ResourceReferenceField.js.map +1 -0
- package/dist/browser/components/platform-fields/RichTextField.d.ts +14 -0
- package/dist/browser/components/platform-fields/RichTextField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/RichTextField.js +214 -0
- package/dist/browser/components/platform-fields/RichTextField.js.map +1 -0
- package/dist/browser/components/platform-fields/SignatureField.d.ts +15 -0
- package/dist/browser/components/platform-fields/SignatureField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/SignatureField.js +179 -0
- package/dist/browser/components/platform-fields/SignatureField.js.map +1 -0
- package/dist/browser/components/platform-fields/SubtableField.d.ts +18 -0
- package/dist/browser/components/platform-fields/SubtableField.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/SubtableField.js +236 -0
- package/dist/browser/components/platform-fields/SubtableField.js.map +1 -0
- package/dist/browser/components/platform-fields/address-value.d.ts +13 -0
- package/dist/browser/components/platform-fields/address-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/address-value.js +70 -0
- package/dist/browser/components/platform-fields/address-value.js.map +1 -0
- package/dist/browser/components/platform-fields/cascade-value.d.ts +6 -0
- package/dist/browser/components/platform-fields/cascade-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/cascade-value.js +47 -0
- package/dist/browser/components/platform-fields/cascade-value.js.map +1 -0
- package/dist/browser/components/platform-fields/directory-value.d.ts +7 -0
- package/dist/browser/components/platform-fields/directory-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/directory-value.js +35 -0
- package/dist/browser/components/platform-fields/directory-value.js.map +1 -0
- package/dist/browser/components/platform-fields/field-form-codec.d.ts +10 -0
- package/dist/browser/components/platform-fields/field-form-codec.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/field-form-codec.js +82 -0
- package/dist/browser/components/platform-fields/field-form-codec.js.map +1 -0
- package/dist/browser/components/platform-fields/location-value.d.ts +20 -0
- package/dist/browser/components/platform-fields/location-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/location-value.js +57 -0
- package/dist/browser/components/platform-fields/location-value.js.map +1 -0
- package/dist/browser/components/platform-fields/resource-query.d.ts +14 -0
- package/dist/browser/components/platform-fields/resource-query.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/resource-query.js +102 -0
- package/dist/browser/components/platform-fields/resource-query.js.map +1 -0
- package/dist/browser/components/platform-fields/rich-text-value.d.ts +12 -0
- package/dist/browser/components/platform-fields/rich-text-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/rich-text-value.js +83 -0
- package/dist/browser/components/platform-fields/rich-text-value.js.map +1 -0
- package/dist/browser/components/platform-fields/subtable-value.d.ts +31 -0
- package/dist/browser/components/platform-fields/subtable-value.d.ts.map +1 -0
- package/dist/browser/components/platform-fields/subtable-value.js +120 -0
- package/dist/browser/components/platform-fields/subtable-value.js.map +1 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts +8 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.d.ts.map +1 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.js +580 -0
- package/dist/browser/components/resource/GeneratedResourceCrud.js.map +1 -0
- package/dist/browser/components/resource/ResourceBatchActions.d.ts +25 -0
- package/dist/browser/components/resource/ResourceBatchActions.d.ts.map +1 -0
- package/dist/browser/components/resource/ResourceBatchActions.js +168 -0
- package/dist/browser/components/resource/ResourceBatchActions.js.map +1 -0
- package/dist/browser/components/resource/StandardResourcePages.d.ts +57 -0
- package/dist/browser/components/resource/StandardResourcePages.d.ts.map +1 -0
- package/dist/browser/components/resource/StandardResourcePages.js +89 -0
- package/dist/browser/components/resource/StandardResourcePages.js.map +1 -0
- package/dist/browser/components/resource/SurfaceFields.d.ts +88 -0
- package/dist/browser/components/resource/SurfaceFields.d.ts.map +1 -0
- package/dist/browser/components/resource/SurfaceFields.js +497 -0
- package/dist/browser/components/resource/SurfaceFields.js.map +1 -0
- package/dist/browser/components/resource/generated-resource-definition.d.ts +19 -0
- package/dist/browser/components/resource/generated-resource-definition.d.ts.map +1 -0
- package/dist/browser/components/resource/generated-resource-definition.js +2 -0
- package/dist/browser/components/resource/generated-resource-definition.js.map +1 -0
- package/dist/browser/components/resource/resource-import.d.ts +15 -0
- package/dist/browser/components/resource/resource-import.d.ts.map +1 -0
- package/dist/browser/components/resource/resource-import.js +197 -0
- package/dist/browser/components/resource/resource-import.js.map +1 -0
- package/dist/browser/data-provider.d.ts +4 -0
- package/dist/browser/data-provider.d.ts.map +1 -0
- package/dist/browser/data-provider.js +45 -0
- package/dist/browser/data-provider.js.map +1 -0
- package/dist/browser/platform-client.d.ts +81 -0
- package/dist/browser/platform-client.d.ts.map +1 -0
- package/dist/browser/platform-client.js +422 -0
- package/dist/browser/platform-client.js.map +1 -0
- package/dist/browser/resource-definitions.d.ts +8 -0
- package/dist/browser/resource-definitions.d.ts.map +1 -0
- package/dist/browser/resource-definitions.js +14 -0
- package/dist/browser/resource-definitions.js.map +1 -0
- package/dist/browser/runtime-meta.d.ts +22 -0
- package/dist/browser/runtime-meta.d.ts.map +1 -0
- package/dist/browser/runtime-meta.js +79 -0
- package/dist/browser/runtime-meta.js.map +1 -0
- package/dist/browser/runtime.d.ts +13 -0
- package/dist/browser/runtime.d.ts.map +1 -0
- package/dist/browser/runtime.js +47 -0
- package/dist/browser/runtime.js.map +1 -0
- package/dist/browser/styles.css +1941 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +6 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -0
- package/dist/field-kit.d.ts +22 -0
- package/dist/field-kit.d.ts.map +1 -0
- package/dist/field-kit.js +22 -0
- package/dist/field-kit.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/nest.d.ts +10 -0
- package/dist/nest.d.ts.map +1 -0
- package/dist/nest.js +9 -0
- package/dist/nest.js.map +1 -0
- package/dist/react.d.ts +12 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +11 -0
- package/dist/react.js.map +1 -0
- package/dist/testing.d.ts +4 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -0
- package/package.json +95 -200
- package/skills/manifest.json +10 -0
- package/skills/openxiangda-v2/SKILL.md +55 -0
- package/skills/openxiangda-v2/references/architecture.md +7 -0
- package/skills/openxiangda-v2/references/backend.md +116 -0
- package/skills/openxiangda-v2/references/data-authz.md +93 -0
- package/skills/openxiangda-v2/references/delivery.md +11 -0
- package/skills/openxiangda-v2/references/discovery.md +15 -0
- package/skills/openxiangda-v2/references/frontend.md +10 -0
- package/skills/openxiangda-v2/references/testing.md +16 -0
- package/skills/openxiangda-v2/references/workflow-notification.md +69 -0
- package/skills/openxiangda-v2/references/workspace.md +21 -0
- package/bin/openxiangda.js +0 -26
- package/lib/app-function-invoke.js +0 -28
- package/lib/application-environments.js +0 -1134
- package/lib/change-baseline.js +0 -1359
- package/lib/cli.js +0 -31084
- package/lib/config.js +0 -450
- package/lib/content-cache.js +0 -97
- package/lib/delivery-v2-cli.js +0 -329
- package/lib/delivery-v2-executor.js +0 -1703
- package/lib/delivery-v2-package.js +0 -1176
- package/lib/dependency-capsule.js +0 -246
- package/lib/design-gates.js +0 -668
- package/lib/design-review.js +0 -220
- package/lib/developer-center.js +0 -160
- package/lib/form-field-contract.js +0 -79
- package/lib/form-schema-loader.js +0 -181
- package/lib/git-remote-identity.js +0 -89
- package/lib/http.js +0 -196
- package/lib/integration-bundle.js +0 -225
- package/lib/js-code-build.js +0 -175
- package/lib/open-api.js +0 -256
- package/lib/policy.js +0 -137
- package/lib/publish-context.js +0 -98
- package/lib/publish-lease-heartbeat.js +0 -182
- package/lib/publish-lease.js +0 -221
- package/lib/release-error-classification.js +0 -41
- package/lib/release-explain.js +0 -75
- package/lib/release-mainline.js +0 -654
- package/lib/release-plan.js +0 -550
- package/lib/release-telemetry.js +0 -182
- package/lib/resource-binding-contract.js +0 -210
- package/lib/role-resolution.js +0 -57
- package/lib/runtime-lineage.js +0 -326
- package/lib/sdd.js +0 -3306
- package/lib/skills.js +0 -453
- package/lib/source-dependencies.js +0 -921
- package/lib/task-status.js +0 -330
- package/lib/utils.js +0 -178
- package/lib/workspace-bootstrap.js +0 -268
- package/lib/workspace-init.js +0 -202
- package/lib/worktree-cleanup.js +0 -631
- package/lib/worktree-owner.js +0 -354
- package/openxiangda-skills/SKILL.md +0 -226
- package/openxiangda-skills/references/architecture-design.md +0 -409
- package/openxiangda-skills/references/architecture-patterns.md +0 -264
- package/openxiangda-skills/references/automation-v3.md +0 -349
- package/openxiangda-skills/references/best-practices.md +0 -272
- package/openxiangda-skills/references/component-guide.md +0 -287
- package/openxiangda-skills/references/connector-resources.md +0 -80
- package/openxiangda-skills/references/data-views.md +0 -360
- package/openxiangda-skills/references/forms/component-registry.md +0 -90
- package/openxiangda-skills/references/forms/form-schema.md +0 -146
- package/openxiangda-skills/references/forms/layout-and-rules.md +0 -24
- package/openxiangda-skills/references/notifications.md +0 -227
- package/openxiangda-skills/references/openxiangda-api.md +0 -971
- package/openxiangda-skills/references/pages/app-shell.md +0 -66
- package/openxiangda-skills/references/pages/page-sdk.md +0 -401
- package/openxiangda-skills/references/pages/publish-flow.md +0 -84
- package/openxiangda-skills/references/pages/workspace-structure.md +0 -41
- package/openxiangda-skills/references/permission-design-patterns.md +0 -313
- package/openxiangda-skills/references/permissions-settings.md +0 -468
- package/openxiangda-skills/references/platform-data-model.md +0 -340
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +0 -936
- package/openxiangda-skills/references/school-contact-relations.md +0 -224
- package/openxiangda-skills/references/style-system.md +0 -218
- package/openxiangda-skills/references/troubleshooting.md +0 -271
- package/openxiangda-skills/references/workflow-v3.md +0 -441
- package/openxiangda-skills/references/workspace-state.md +0 -115
- package/openxiangda-skills/skills/openxiangda-app/SKILL.md +0 -118
- package/openxiangda-skills/skills/openxiangda-architecture-design/SKILL.md +0 -137
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +0 -222
- package/openxiangda-skills/skills/openxiangda-form/SKILL.md +0 -184
- package/openxiangda-skills/skills/openxiangda-inspect/SKILL.md +0 -63
- package/openxiangda-skills/skills/openxiangda-open-api/SKILL.md +0 -57
- package/openxiangda-skills/skills/openxiangda-open-api/agents/openai.yaml +0 -4
- package/openxiangda-skills/skills/openxiangda-open-api/references/backend-authentication.md +0 -63
- package/openxiangda-skills/skills/openxiangda-open-api/references/dingtalk-api.openapi.json +0 -15653
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +0 -154
- package/openxiangda-skills/skills/openxiangda-permission-settings/SKILL.md +0 -209
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +0 -201
- package/packages/sdk/bin/lowcode-workspace.mjs +0 -4
- package/packages/sdk/dist/ProcessPreview-DSUIJi5V.d.mts +0 -1292
- package/packages/sdk/dist/ProcessPreview-DSUIJi5V.d.ts +0 -1292
- package/packages/sdk/dist/build/index.cjs +0 -1
- package/packages/sdk/dist/build/index.d.mts +0 -60
- package/packages/sdk/dist/build/index.d.ts +0 -60
- package/packages/sdk/dist/build/index.mjs +0 -1
- package/packages/sdk/dist/components/index.cjs +0 -148
- package/packages/sdk/dist/components/index.d.mts +0 -970
- package/packages/sdk/dist/components/index.d.ts +0 -970
- package/packages/sdk/dist/components/index.mjs +0 -148
- package/packages/sdk/dist/dataManagementApi-Ro9itwm8.d.ts +0 -142
- package/packages/sdk/dist/dataManagementApi-p_HOhQnA.d.mts +0 -142
- package/packages/sdk/dist/runtime/index.cjs +0 -148
- package/packages/sdk/dist/runtime/index.d.mts +0 -171
- package/packages/sdk/dist/runtime/index.d.ts +0 -171
- package/packages/sdk/dist/runtime/index.mjs +0 -148
- package/packages/sdk/dist/runtime/react.cjs +0 -148
- package/packages/sdk/dist/runtime/react.d.mts +0 -3202
- package/packages/sdk/dist/runtime/react.d.ts +0 -3202
- package/packages/sdk/dist/runtime/react.mjs +0 -148
- package/packages/sdk/dist/styles/antd-theme.cjs +0 -1
- package/packages/sdk/dist/styles/antd-theme.d.mts +0 -6
- package/packages/sdk/dist/styles/antd-theme.d.ts +0 -6
- package/packages/sdk/dist/styles/antd-theme.mjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.mts +0 -74
- package/packages/sdk/dist/styles/tailwind-preset.d.ts +0 -74
- package/packages/sdk/dist/styles/tailwind-preset.mjs +0 -1
- package/packages/sdk/dist/styles/tokens.css +0 -74
- package/packages/sdk/dist/workflow/index.cjs +0 -3
- package/packages/sdk/dist/workflow/index.d.mts +0 -291
- package/packages/sdk/dist/workflow/index.d.ts +0 -291
- package/packages/sdk/dist/workflow/index.mjs +0 -3
- package/packages/sdk/source/admin-list/AdminList.tsx +0 -1734
- package/packages/sdk/source/admin-list/README.md +0 -12
- package/packages/sdk/source/admin-list/dataSources.ts +0 -345
- package/packages/sdk/source/admin-list/index.ts +0 -42
- package/packages/sdk/source/admin-list/preferences.ts +0 -174
- package/packages/sdk/source/admin-list/types.ts +0 -273
- package/packages/sdk/src/build-source/README.md +0 -9
- package/packages/sdk/src/build-source/bin/lowcode-workspace.mjs +0 -7
- package/packages/sdk/src/build-source/package.json +0 -34
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +0 -1129
- package/packages/sdk/src/build-source/scripts/build-pages.mjs +0 -897
- package/packages/sdk/src/build-source/scripts/build-workspace.mjs +0 -89
- package/packages/sdk/src/build-source/scripts/publish-all.mjs +0 -190
- package/packages/sdk/src/build-source/scripts/publish-oss.mjs +0 -144
- package/packages/sdk/src/build-source/scripts/register-bundle.mjs +0 -1
- package/packages/sdk/src/build-source/scripts/register.mjs +0 -362
- package/packages/sdk/src/build-source/scripts/sync-schema.mjs +0 -381
- package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +0 -1058
- package/packages/sdk/src/build-source/scripts/utils/form-runtime-assets.mjs +0 -57
- package/packages/sdk/src/build-source/scripts/utils/incremental.mjs +0 -348
- package/packages/sdk/src/build-source/scripts/utils/load-config.mjs +0 -331
- package/packages/sdk/src/build-source/scripts/utils/mime-types.mjs +0 -70
- package/packages/sdk/src/build-source/scripts/utils/namespace-css.mjs +0 -77
- package/packages/sdk/src/build-source/scripts/utils/oss-client.mjs +0 -128
- package/packages/sdk/src/build-source/scripts/utils/pages.mjs +0 -150
- package/packages/sdk/src/build-source/scripts/utils/progress.mjs +0 -57
- package/packages/sdk/src/build-source/scripts/utils/publish-oss-patterns.mjs +0 -20
- package/packages/sdk/src/build-source/scripts/utils/register-payload.mjs +0 -90
- package/packages/sdk/src/build-source/scripts/utils/runtime-css-check.mjs +0 -44
- package/packages/sdk/src/build-source/scripts/utils/schema-transform.mjs +0 -142
- package/packages/sdk/src/build-source/scripts/utils/static-assets.mjs +0 -165
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.mjs +0 -283
- package/packages/sdk/src/build-source/scripts/utils/tailwind-token-warnings.mjs +0 -146
- package/packages/sdk/src/build-source/scripts/utils/workspace-style-entry.mjs +0 -29
- package/packages/sdk/src/build-source/src/cli.mjs +0 -735
- package/policy/openxiangda-policy.json +0 -72
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-form.mdc +0 -24
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-page.mdc +0 -25
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-resources.mdc +0 -32
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda-workflow-automation.mdc +0 -26
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda.mdc +0 -68
- package/templates/openxiangda-react-spa/.env.example +0 -4
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-form.md +0 -37
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-page.md +0 -29
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-resources.md +0 -32
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda-workflow-automation.md +0 -34
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda.md +0 -66
- package/templates/openxiangda-react-spa/AGENTS.md +0 -192
- package/templates/openxiangda-react-spa/DELIVERY.md +0 -43
- package/templates/openxiangda-react-spa/app-workspace.config.ts +0 -50
- package/templates/openxiangda-react-spa/index.html +0 -12
- package/templates/openxiangda-react-spa/package.json +0 -53
- package/templates/openxiangda-react-spa/postcss.config.cjs +0 -6
- package/templates/openxiangda-react-spa/scripts/build-js-code.mjs +0 -600
- package/templates/openxiangda-react-spa/scripts/deploy.mjs +0 -18
- package/templates/openxiangda-react-spa/scripts/guard-publish.mjs +0 -21
- package/templates/openxiangda-react-spa/src/app/navigation.ts +0 -73
- package/templates/openxiangda-react-spa/src/app/router.tsx +0 -146
- package/templates/openxiangda-react-spa/src/app/starter-content.ts +0 -144
- package/templates/openxiangda-react-spa/src/forms/.gitkeep +0 -1
- package/templates/openxiangda-react-spa/src/layouts/AdminShell.tsx +0 -570
- package/templates/openxiangda-react-spa/src/main.tsx +0 -21
- package/templates/openxiangda-react-spa/src/pages/admin/AdminDashboardPage.tsx +0 -170
- package/templates/openxiangda-react-spa/src/pages/admin/LoginLogPage.tsx +0 -425
- package/templates/openxiangda-react-spa/src/pages/defaults/DataRoutePage.tsx +0 -36
- package/templates/openxiangda-react-spa/src/pages/defaults/FilePreviewRoutePage.tsx +0 -65
- package/templates/openxiangda-react-spa/src/pages/defaults/FormRoutePage.tsx +0 -235
- package/templates/openxiangda-react-spa/src/pages/public/PublicRegisterPage.tsx +0 -15
- package/templates/openxiangda-react-spa/src/pages/states/NotFoundPage.tsx +0 -31
- package/templates/openxiangda-react-spa/src/resources/menus/menus.json +0 -22
- package/templates/openxiangda-react-spa/src/resources/permissions/page-groups/app-admin.json +0 -8
- package/templates/openxiangda-react-spa/src/resources/permissions/page-groups/public-visitor.json +0 -8
- package/templates/openxiangda-react-spa/src/resources/public-access/public-register.json +0 -14
- package/templates/openxiangda-react-spa/src/resources/roles/roles.json +0 -15
- package/templates/openxiangda-react-spa/src/resources/routes/public-register.json +0 -8
- package/templates/openxiangda-react-spa/src/runtime/default-page-overrides.tsx +0 -35
- package/templates/openxiangda-react-spa/src/runtime/default-routes.ts +0 -16
- package/templates/openxiangda-react-spa/src/shared/form-schema.ts +0 -135
- package/templates/openxiangda-react-spa/src/shared/mac-admin.tsx +0 -651
- package/templates/openxiangda-react-spa/src/shared/ui.tsx +0 -22
- package/templates/openxiangda-react-spa/src/styles/index.css +0 -105
- package/templates/openxiangda-react-spa/tailwind.config.cjs +0 -37
- package/templates/openxiangda-react-spa/tsconfig.app.json +0 -36
- package/templates/openxiangda-react-spa/tsconfig.js-code-nodes.json +0 -19
- package/templates/openxiangda-react-spa/tsconfig.json +0 -7
- package/templates/openxiangda-react-spa/tsconfig.node.json +0 -10
- package/templates/openxiangda-react-spa/vite.config.ts +0 -209
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-form.mdc +0 -24
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-page.mdc +0 -21
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-resources.mdc +0 -40
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda-workflow-automation.mdc +0 -21
- package/templates/sy-lowcode-app-workspace/.cursor/rules/openxiangda.mdc +0 -81
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-form.md +0 -38
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-page.md +0 -39
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-resources.md +0 -59
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda-workflow-automation.md +0 -46
- package/templates/sy-lowcode-app-workspace/.qoder/rules/openxiangda.md +0 -82
- package/templates/sy-lowcode-app-workspace/AGENTS.md +0 -158
- package/templates/sy-lowcode-app-workspace/DELIVERY.md +0 -43
- package/templates/sy-lowcode-app-workspace/app-workspace.config.ts +0 -51
- package/templates/sy-lowcode-app-workspace/examples/best-practices/README.md +0 -43
- package/templates/sy-lowcode-app-workspace/examples/best-practices/access-governance.md +0 -239
- package/templates/sy-lowcode-app-workspace/examples/best-practices/catalog.json +0 -99
- package/templates/sy-lowcode-app-workspace/examples/best-practices/decision-guide.md +0 -94
- package/templates/sy-lowcode-app-workspace/examples/best-practices/design-style.md +0 -91
- package/templates/sy-lowcode-app-workspace/examples/best-practices/module-structure.md +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/index.ts +0 -2
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.test.ts +0 -52
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.ts +0 -37
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/types.ts +0 -19
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/index.ts +0 -4
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.test.ts +0 -42
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/permissions.ts +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.test.ts +0 -63
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/state-machine.ts +0 -73
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.test.ts +0 -34
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/ticket-query.ts +0 -73
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/service-ticket/types.ts +0 -66
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/schema.ts +0 -109
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/customer-profile/schema.ts +0 -92
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/schema.ts +0 -153
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/ticket-action-log/schema.ts +0 -65
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/daily_ticket_digest/index.ts +0 -44
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/js-code-nodes/sync_roles_to_platform/index.ts +0 -33
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/GlassHomeDashboard.tsx +0 -232
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/glass-home-dashboard/styles.css +0 -196
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/WorkbenchPage.tsx +0 -36
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/ConfigPanel.tsx +0 -34
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/components/PreviewPanel.tsx +0 -17
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/page.config.ts +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/reducer.ts +0 -29
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/interactive-workbench/styles.css +0 -24
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/MintAnalyticsDashboard.tsx +0 -279
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mint-analytics-dashboard/styles.css +0 -163
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/MobilePortalShell.tsx +0 -31
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/modules/MobileHome.tsx +0 -13
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/routes.ts +0 -13
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/mobile-portal-shell/styles.css +0 -11
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/OpsMonitorDashboard.tsx +0 -306
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/ops-monitor-dashboard/styles.css +0 -248
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/PcPortalShell.tsx +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/components/PortalMetric.tsx +0 -11
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/HomeModule.tsx +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/modules/TicketsModule.tsx +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/routes.ts +0 -19
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/pc-portal-shell/styles.css +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/App.tsx +0 -7
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/TicketOpsPage.tsx +0 -105
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketActionTimeline.tsx +0 -22
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketDetailDrawer.tsx +0 -44
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/components/TicketTableActions.tsx +0 -57
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/page.config.ts +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/service-ticket-ops/styles.css +0 -35
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/App.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/WorkOrderListDrawerPage.tsx +0 -371
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/index.tsx +0 -10
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/page.config.ts +0 -14
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/pages/work-order-list-drawer/styles.css +0 -182
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/automation.json +0 -25
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/automations/daily-ticket-digest/trigger.json +0 -9
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/notifications/daily-ticket-digest.json +0 -24
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/form-groups/service-ticket-college.json +0 -21
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/permissions/roles.json +0 -17
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/resources/workflows/expense-approval-workflow.json +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/ConfirmAction.tsx +0 -22
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/QueryState.tsx +0 -37
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/StatusTag.tsx +0 -20
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/DashboardPrimitives.tsx +0 -832
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/chartOptions.ts +0 -140
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/sampleData.ts +0 -466
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/styles.css +0 -874
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/components/admin-ui-templates/types.ts +0 -150
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/hooks/useTicketOps.ts +0 -96
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/role-governance.ts +0 -48
- package/templates/sy-lowcode-app-workspace/examples/best-practices/src/shared/services/service-ticket.ts +0 -113
- package/templates/sy-lowcode-app-workspace/examples/forms/customer/page.tsx +0 -1
- package/templates/sy-lowcode-app-workspace/examples/forms/customer/schema.ts +0 -36
- package/templates/sy-lowcode-app-workspace/index.html +0 -12
- package/templates/sy-lowcode-app-workspace/package.json +0 -58
- package/templates/sy-lowcode-app-workspace/postcss.config.cjs +0 -9
- package/templates/sy-lowcode-app-workspace/scripts/build-js-code.mjs +0 -600
- package/templates/sy-lowcode-app-workspace/scripts/guard-publish.mjs +0 -29
- package/templates/sy-lowcode-app-workspace/src/dev/App.tsx +0 -820
- package/templates/sy-lowcode-app-workspace/src/forms/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/forms/README.md +0 -52
- package/templates/sy-lowcode-app-workspace/src/index.css +0 -26
- package/templates/sy-lowcode-app-workspace/src/js-code-nodes/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/js-code-nodes/types.d.ts +0 -3
- package/templates/sy-lowcode-app-workspace/src/main.tsx +0 -29
- package/templates/sy-lowcode-app-workspace/src/pages/.gitkeep +0 -1
- package/templates/sy-lowcode-app-workspace/src/runtime/builtin-overrides.tsx +0 -8
- package/templates/sy-lowcode-app-workspace/src/shared/form-schema.ts +0 -135
- package/templates/sy-lowcode-app-workspace/src/types/app-workspace.types.ts +0 -88
- package/templates/sy-lowcode-app-workspace/tailwind.config.cjs +0 -31
- package/templates/sy-lowcode-app-workspace/tsconfig.app.json +0 -40
- package/templates/sy-lowcode-app-workspace/tsconfig.examples.json +0 -24
- package/templates/sy-lowcode-app-workspace/tsconfig.js-code-nodes.json +0 -19
- package/templates/sy-lowcode-app-workspace/tsconfig.json +0 -7
- package/templates/sy-lowcode-app-workspace/tsconfig.node.json +0 -10
- package/templates/sy-lowcode-app-workspace/vite.config.ts +0 -85
- package/v2/README.md +0 -35
- package/v2/skills/manifest.json +0 -45
- package/v2/skills/openxiangda-v1-maintenance/SKILL.md +0 -21
- package/v2/skills/openxiangda-v1-maintenance/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2/SKILL.md +0 -38
- package/v2/skills/openxiangda-v2-architecture/SKILL.md +0 -29
- package/v2/skills/openxiangda-v2-architecture/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-backend/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-backend/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-data-authz/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-data-authz/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-delivery/SKILL.md +0 -30
- package/v2/skills/openxiangda-v2-delivery/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-frontend/SKILL.md +0 -21
- package/v2/skills/openxiangda-v2-frontend/agents/openai.yaml +0 -4
- package/v2/skills/openxiangda-v2-workflow-events/SKILL.md +0 -28
- package/v2/skills/openxiangda-v2-workflow-events/agents/openai.yaml +0 -4
- /package/{v2/skills → skills}/openxiangda-v2/agents/openai.yaml +0 -0
|
@@ -1,1176 +0,0 @@
|
|
|
1
|
-
const crypto = require('crypto');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { spawn } = require('child_process');
|
|
5
|
-
const { builtinModules } = require('module');
|
|
6
|
-
|
|
7
|
-
const PACKAGE_SCHEMA_VERSION = 'openxiangda-app-package-v2';
|
|
8
|
-
const COMPILER_VERSION = 'delivery-v2.1';
|
|
9
|
-
const MAX_RUNTIME_BYTES = 25 * 1024 * 1024;
|
|
10
|
-
|
|
11
|
-
const ROOT_SOURCE_FILES = new Set([
|
|
12
|
-
'app-workspace.config.ts',
|
|
13
|
-
'index.html',
|
|
14
|
-
'package.json',
|
|
15
|
-
'package-lock.json',
|
|
16
|
-
'pnpm-lock.yaml',
|
|
17
|
-
'pnpm-workspace.yaml',
|
|
18
|
-
'yarn.lock',
|
|
19
|
-
'postcss.config.cjs',
|
|
20
|
-
'postcss.config.js',
|
|
21
|
-
'tailwind.config.cjs',
|
|
22
|
-
'tailwind.config.js',
|
|
23
|
-
'tsconfig.app.json',
|
|
24
|
-
'tsconfig.json',
|
|
25
|
-
'tsconfig.node.json',
|
|
26
|
-
'vite.config.js',
|
|
27
|
-
'vite.config.mjs',
|
|
28
|
-
'vite.config.ts',
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const IGNORED_SEGMENTS = new Set([
|
|
32
|
-
'.git',
|
|
33
|
-
'.openxiangda',
|
|
34
|
-
'.turbo',
|
|
35
|
-
'coverage',
|
|
36
|
-
'dist',
|
|
37
|
-
'node_modules',
|
|
38
|
-
'openspec',
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
const LAYER_ORDER = [
|
|
42
|
-
'source',
|
|
43
|
-
'form',
|
|
44
|
-
'configuration',
|
|
45
|
-
'backend',
|
|
46
|
-
'workflow',
|
|
47
|
-
'runtime',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const CONFIG_RESOURCE_TYPES = Object.freeze({
|
|
51
|
-
'src/resources/roles/': 'role',
|
|
52
|
-
'src/resources/connectors/': 'connector',
|
|
53
|
-
'src/resources/notifications/': 'notification',
|
|
54
|
-
'src/resources/menus/': 'menu',
|
|
55
|
-
'src/resources/data-views/': 'data-view',
|
|
56
|
-
'src/resources/storage/': 'storage',
|
|
57
|
-
'src/resources/auth/': 'auth-config',
|
|
58
|
-
'src/resources/routes/': 'route',
|
|
59
|
-
'src/resources/public-access/': 'public-access',
|
|
60
|
-
'src/resources/permissions/page-groups/': 'page-permission-group',
|
|
61
|
-
'src/resources/permissions/form-groups/': 'form-permission-group',
|
|
62
|
-
'src/resources/permissions/scope-dimensions/': 'scope-dimension',
|
|
63
|
-
'src/resources/permissions/scope-grant-sources/': 'scope-grant-source',
|
|
64
|
-
'src/resources/permissions/data-scope-policies/': 'data-scope-policy',
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
function canonicalize(value) {
|
|
68
|
-
if (Array.isArray(value)) return value.map(canonicalize);
|
|
69
|
-
if (value && typeof value === 'object') {
|
|
70
|
-
return Object.keys(value)
|
|
71
|
-
.sort()
|
|
72
|
-
.reduce((result, key) => {
|
|
73
|
-
if (value[key] !== undefined) result[key] = canonicalize(value[key]);
|
|
74
|
-
return result;
|
|
75
|
-
}, {});
|
|
76
|
-
}
|
|
77
|
-
if (typeof value === 'number' && !Number.isFinite(value)) {
|
|
78
|
-
return String(value);
|
|
79
|
-
}
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function canonicalJson(value) {
|
|
84
|
-
return JSON.stringify(canonicalize(value));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function sha256(buffer) {
|
|
88
|
-
return crypto.createHash('sha256').update(buffer).digest('hex');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function sha256Canonical(value) {
|
|
92
|
-
return sha256(Buffer.from(canonicalJson(value)));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function normalizePath(value) {
|
|
96
|
-
return String(value || '').replace(/\\/g, '/').replace(/^\.\/+/, '');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function isSecretFile(relativePath) {
|
|
100
|
-
const normalized = normalizePath(relativePath);
|
|
101
|
-
const base = path.posix.basename(normalized);
|
|
102
|
-
if (base === '.env.example') return false;
|
|
103
|
-
return (
|
|
104
|
-
base === '.env' ||
|
|
105
|
-
base.startsWith('.env.') ||
|
|
106
|
-
/\.(pem|p12|pfx|key)$/i.test(base)
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function shouldIncludeSourceFile(relativePath) {
|
|
111
|
-
const normalized = normalizePath(relativePath);
|
|
112
|
-
if (!normalized || isSecretFile(normalized)) return false;
|
|
113
|
-
const segments = normalized.split('/');
|
|
114
|
-
if (segments.some(segment => IGNORED_SEGMENTS.has(segment))) return false;
|
|
115
|
-
if (ROOT_SOURCE_FILES.has(normalized)) return true;
|
|
116
|
-
if (/^tsconfig(?:\.[^/]+)?\.json$/.test(normalized)) return true;
|
|
117
|
-
return (
|
|
118
|
-
normalized.startsWith('src/') ||
|
|
119
|
-
normalized.startsWith('public/') ||
|
|
120
|
-
normalized.startsWith('scripts/')
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function walkFiles(rootDir, currentDir = rootDir, result = []) {
|
|
125
|
-
const entries = fs
|
|
126
|
-
.readdirSync(currentDir, { withFileTypes: true })
|
|
127
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
128
|
-
for (const entry of entries) {
|
|
129
|
-
const absolute = path.join(currentDir, entry.name);
|
|
130
|
-
const relative = normalizePath(path.relative(rootDir, absolute));
|
|
131
|
-
if (entry.isDirectory()) {
|
|
132
|
-
if (IGNORED_SEGMENTS.has(entry.name)) continue;
|
|
133
|
-
walkFiles(rootDir, absolute, result);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
if (!entry.isFile() || !shouldIncludeSourceFile(relative)) continue;
|
|
137
|
-
result.push(relative);
|
|
138
|
-
}
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function layerForSourceFile(relativePath) {
|
|
143
|
-
const file = normalizePath(relativePath);
|
|
144
|
-
if (
|
|
145
|
-
file.startsWith('src/forms/') ||
|
|
146
|
-
file.startsWith('src/resources/forms/')
|
|
147
|
-
) {
|
|
148
|
-
return 'form';
|
|
149
|
-
}
|
|
150
|
-
if (
|
|
151
|
-
file.startsWith('src/functions/') ||
|
|
152
|
-
file.startsWith('src/automations/') ||
|
|
153
|
-
file.startsWith('src/js-code-nodes/') ||
|
|
154
|
-
file.startsWith('src/resources/functions/') ||
|
|
155
|
-
file.startsWith('src/resources/automations/')
|
|
156
|
-
) {
|
|
157
|
-
return 'backend';
|
|
158
|
-
}
|
|
159
|
-
if (
|
|
160
|
-
file.startsWith('src/workflows/') ||
|
|
161
|
-
file.startsWith('src/resources/workflows/')
|
|
162
|
-
) {
|
|
163
|
-
return 'workflow';
|
|
164
|
-
}
|
|
165
|
-
if (file.startsWith('src/resources/')) return 'configuration';
|
|
166
|
-
return 'runtime';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function artifactFromBuffer(kind, buffer, metadata = {}) {
|
|
170
|
-
return {
|
|
171
|
-
digest: sha256(buffer),
|
|
172
|
-
kind,
|
|
173
|
-
contentType: metadata.contentType || 'application/octet-stream',
|
|
174
|
-
size: buffer.length,
|
|
175
|
-
buffer,
|
|
176
|
-
metadata: {
|
|
177
|
-
...metadata,
|
|
178
|
-
contentType: undefined,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function fileDescriptor(artifact, relativePath) {
|
|
184
|
-
return {
|
|
185
|
-
path: normalizePath(relativePath),
|
|
186
|
-
digest: artifact.digest,
|
|
187
|
-
size: artifact.size,
|
|
188
|
-
contentType: artifact.contentType,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function sourceArtifacts(workspaceRoot) {
|
|
193
|
-
return walkFiles(workspaceRoot).map(relativePath => {
|
|
194
|
-
const buffer = fs.readFileSync(path.join(workspaceRoot, relativePath));
|
|
195
|
-
const artifact = artifactFromBuffer('source', buffer, {
|
|
196
|
-
path: relativePath,
|
|
197
|
-
contentType: inferContentType(relativePath),
|
|
198
|
-
});
|
|
199
|
-
return {
|
|
200
|
-
relativePath,
|
|
201
|
-
category: layerForSourceFile(relativePath),
|
|
202
|
-
artifact,
|
|
203
|
-
descriptor: fileDescriptor(artifact, relativePath),
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function sourceHashForCategory(files, category) {
|
|
209
|
-
return sha256Canonical(
|
|
210
|
-
files
|
|
211
|
-
.filter(file => category === 'source' || file.category === category)
|
|
212
|
-
.map(file => ({
|
|
213
|
-
path: file.relativePath,
|
|
214
|
-
digest: file.artifact.digest,
|
|
215
|
-
size: file.artifact.size,
|
|
216
|
-
}))
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function collectUnsealedBuildDependencies(files) {
|
|
221
|
-
const builtins = new Set([
|
|
222
|
-
...builtinModules,
|
|
223
|
-
...builtinModules.map(name => `node:${name}`),
|
|
224
|
-
]);
|
|
225
|
-
const filesByPath = new Map(
|
|
226
|
-
files.map(file => [normalizePath(file.relativePath), file])
|
|
227
|
-
);
|
|
228
|
-
const pending = files
|
|
229
|
-
.filter(file =>
|
|
230
|
-
['form', 'backend', 'workflow'].includes(file.category)
|
|
231
|
-
)
|
|
232
|
-
.filter(file => /\.(?:[cm]?js|tsx?)$/.test(file.relativePath));
|
|
233
|
-
const visited = new Set();
|
|
234
|
-
const dependencies = new Set();
|
|
235
|
-
const missingLocalDependencies = new Set();
|
|
236
|
-
const importPattern =
|
|
237
|
-
/(?:\bfrom\s*|\bimport\s*\(|\brequire\s*\(|\bimport\s+)\s*['"]([^'"]+)['"]/g;
|
|
238
|
-
while (pending.length > 0) {
|
|
239
|
-
const file = pending.shift();
|
|
240
|
-
if (visited.has(file.relativePath)) continue;
|
|
241
|
-
visited.add(file.relativePath);
|
|
242
|
-
const source = file.artifact.buffer.toString('utf8');
|
|
243
|
-
let match;
|
|
244
|
-
while ((match = importPattern.exec(source))) {
|
|
245
|
-
const specifier = String(match[1] || '').trim();
|
|
246
|
-
const localDependency = resolveLocalSourceDependency(
|
|
247
|
-
file.relativePath,
|
|
248
|
-
specifier,
|
|
249
|
-
filesByPath
|
|
250
|
-
);
|
|
251
|
-
if (localDependency) {
|
|
252
|
-
pending.push(localDependency);
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (specifier.startsWith('.') || specifier.startsWith('@/')) {
|
|
256
|
-
missingLocalDependencies.add(
|
|
257
|
-
`${file.relativePath} -> ${specifier}`
|
|
258
|
-
);
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (
|
|
262
|
-
!specifier ||
|
|
263
|
-
specifier.startsWith('.') ||
|
|
264
|
-
specifier.startsWith('/') ||
|
|
265
|
-
specifier.startsWith('@/') ||
|
|
266
|
-
specifier === 'openxiangda' ||
|
|
267
|
-
specifier.startsWith('openxiangda/') ||
|
|
268
|
-
builtins.has(specifier) ||
|
|
269
|
-
builtins.has(specifier.split('/')[0])
|
|
270
|
-
) {
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
dependencies.add(
|
|
274
|
-
specifier.startsWith('@')
|
|
275
|
-
? specifier.split('/').slice(0, 2).join('/')
|
|
276
|
-
: specifier.split('/')[0]
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
externalPackages: [...dependencies].sort(),
|
|
282
|
-
missingLocalDependencies: [...missingLocalDependencies].sort(),
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function resolveLocalSourceDependency(fromPath, specifier, filesByPath) {
|
|
287
|
-
if (!specifier) return null;
|
|
288
|
-
let base;
|
|
289
|
-
if (specifier.startsWith('@/')) {
|
|
290
|
-
base = path.posix.join('src', specifier.slice(2));
|
|
291
|
-
} else if (specifier.startsWith('.')) {
|
|
292
|
-
base = path.posix.normalize(
|
|
293
|
-
path.posix.join(path.posix.dirname(fromPath), specifier)
|
|
294
|
-
);
|
|
295
|
-
} else {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
for (const candidate of [
|
|
299
|
-
base,
|
|
300
|
-
...['.ts', '.tsx', '.js', '.mjs', '.cjs', '.json'].map(
|
|
301
|
-
extension => `${base}${extension}`
|
|
302
|
-
),
|
|
303
|
-
...['.ts', '.tsx', '.js', '.mjs', '.cjs'].map(extension =>
|
|
304
|
-
path.posix.join(base, `index${extension}`)
|
|
305
|
-
),
|
|
306
|
-
]) {
|
|
307
|
-
if (filesByPath.has(candidate)) return filesByPath.get(candidate);
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function discoverResourceInventory(workspaceRoot, files) {
|
|
313
|
-
const sourcePaths = new Set(files.map(file => file.relativePath));
|
|
314
|
-
const filesByPath = new Map(
|
|
315
|
-
files.map(file => [normalizePath(file.relativePath), file])
|
|
316
|
-
);
|
|
317
|
-
const inventory = {
|
|
318
|
-
forms: new Set(),
|
|
319
|
-
functions: new Set(),
|
|
320
|
-
automations: new Set(),
|
|
321
|
-
workflows: new Set(),
|
|
322
|
-
configuration: new Map(),
|
|
323
|
-
};
|
|
324
|
-
const fingerprints = {
|
|
325
|
-
forms: new Map(),
|
|
326
|
-
functions: new Map(),
|
|
327
|
-
automations: new Map(),
|
|
328
|
-
workflows: new Map(),
|
|
329
|
-
configuration: new Map(),
|
|
330
|
-
};
|
|
331
|
-
const assignedFingerprintPaths = new Map();
|
|
332
|
-
const dependencyForms = {
|
|
333
|
-
configuration: new Map(),
|
|
334
|
-
backend: new Map(),
|
|
335
|
-
workflow: new Map(),
|
|
336
|
-
};
|
|
337
|
-
const formPermissionGroupForms = new Map();
|
|
338
|
-
const automationSourceFilesByCode = new Map();
|
|
339
|
-
const addFingerprint = (bucket, code, file) => {
|
|
340
|
-
if (!code || !file) return;
|
|
341
|
-
if (!bucket.has(code)) bucket.set(code, new Map());
|
|
342
|
-
bucket.get(code).set(file.relativePath, file.artifact.digest);
|
|
343
|
-
if (!assignedFingerprintPaths.has(file.category)) {
|
|
344
|
-
assignedFingerprintPaths.set(file.category, new Set());
|
|
345
|
-
}
|
|
346
|
-
assignedFingerprintPaths.get(file.category).add(file.relativePath);
|
|
347
|
-
};
|
|
348
|
-
const addManifestLocalSources = (bucket, code, value, manifestPath) => {
|
|
349
|
-
for (const localPath of collectLocalSourcePaths(value)) {
|
|
350
|
-
const sourceFile = resolvePackagedSourceFile(
|
|
351
|
-
localPath,
|
|
352
|
-
manifestPath,
|
|
353
|
-
filesByPath
|
|
354
|
-
);
|
|
355
|
-
if (sourceFile) addFingerprint(bucket, code, sourceFile);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
const configurationFingerprintBucket = type => {
|
|
359
|
-
if (!fingerprints.configuration.has(type)) {
|
|
360
|
-
fingerprints.configuration.set(type, new Map());
|
|
361
|
-
}
|
|
362
|
-
return fingerprints.configuration.get(type);
|
|
363
|
-
};
|
|
364
|
-
const addDependencyForms = (category, owner, forms) => {
|
|
365
|
-
if (!dependencyForms[category] || !owner) return;
|
|
366
|
-
if (!dependencyForms[category].has(owner)) {
|
|
367
|
-
dependencyForms[category].set(owner, new Set());
|
|
368
|
-
}
|
|
369
|
-
const target = dependencyForms[category].get(owner);
|
|
370
|
-
for (const formCode of forms || []) target.add(formCode);
|
|
371
|
-
};
|
|
372
|
-
const addConfiguration = (type, code) => {
|
|
373
|
-
if (!type || !code) return;
|
|
374
|
-
if (!inventory.configuration.has(type)) {
|
|
375
|
-
inventory.configuration.set(type, new Set());
|
|
376
|
-
}
|
|
377
|
-
inventory.configuration.get(type).add(code);
|
|
378
|
-
};
|
|
379
|
-
for (const file of files) {
|
|
380
|
-
const relative = file.relativePath;
|
|
381
|
-
for (const [prefix, bucket, fingerprintBucket] of [
|
|
382
|
-
['src/forms/', inventory.forms, fingerprints.forms],
|
|
383
|
-
['src/functions/', inventory.functions, fingerprints.functions],
|
|
384
|
-
['src/automations/', inventory.automations, fingerprints.automations],
|
|
385
|
-
['src/workflows/', inventory.workflows, fingerprints.workflows],
|
|
386
|
-
]) {
|
|
387
|
-
if (relative.startsWith(prefix)) {
|
|
388
|
-
const segments = relative.slice(prefix.length).split('/');
|
|
389
|
-
const code = segments[0];
|
|
390
|
-
// Resource source lives under src/<kind>/<code>/... . Files directly
|
|
391
|
-
// under src/forms (for example member-common.ts) are shared helpers,
|
|
392
|
-
// not deployable resources.
|
|
393
|
-
if (!code || code.startsWith('.') || segments.length < 2) continue;
|
|
394
|
-
if (
|
|
395
|
-
prefix === 'src/forms/' &&
|
|
396
|
-
!sourcePaths.has(`src/forms/${code}/schema.ts`)
|
|
397
|
-
) {
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
if (prefix === 'src/automations/') {
|
|
401
|
-
if (!automationSourceFilesByCode.has(code)) {
|
|
402
|
-
automationSourceFilesByCode.set(code, []);
|
|
403
|
-
}
|
|
404
|
-
automationSourceFilesByCode.get(code).push(file);
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
bucket.add(code);
|
|
408
|
-
addFingerprint(fingerprintBucket, code, file);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (!relative.endsWith('.json')) continue;
|
|
412
|
-
const absolute = path.join(workspaceRoot, relative);
|
|
413
|
-
let value;
|
|
414
|
-
try {
|
|
415
|
-
value = JSON.parse(fs.readFileSync(absolute, 'utf8'));
|
|
416
|
-
} catch {
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
const codes = collectManifestCodes(value);
|
|
420
|
-
const referencedForms = collectReferencedFormCodes(value);
|
|
421
|
-
for (const [prefix, category, kind] of [
|
|
422
|
-
['src/functions/', 'backend', 'function'],
|
|
423
|
-
['src/automations/', 'backend', 'automation'],
|
|
424
|
-
['src/workflows/', 'workflow', 'workflow'],
|
|
425
|
-
]) {
|
|
426
|
-
if (!relative.startsWith(prefix)) continue;
|
|
427
|
-
const owner = relative.slice(prefix.length).split('/')[0];
|
|
428
|
-
if (owner && !owner.startsWith('.')) {
|
|
429
|
-
addDependencyForms(category, `${kind}:${owner}`, referencedForms);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if (relative.startsWith('src/resources/forms/')) {
|
|
433
|
-
for (const code of codes) {
|
|
434
|
-
inventory.forms.add(code);
|
|
435
|
-
addFingerprint(fingerprints.forms, code, file);
|
|
436
|
-
addManifestLocalSources(fingerprints.forms, code, value, relative);
|
|
437
|
-
}
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
if (relative.startsWith('src/resources/functions/')) {
|
|
441
|
-
for (const code of codes) {
|
|
442
|
-
inventory.functions.add(code);
|
|
443
|
-
addFingerprint(fingerprints.functions, code, file);
|
|
444
|
-
addManifestLocalSources(
|
|
445
|
-
fingerprints.functions,
|
|
446
|
-
code,
|
|
447
|
-
value,
|
|
448
|
-
relative
|
|
449
|
-
);
|
|
450
|
-
addDependencyForms('backend', `function:${code}`, referencedForms);
|
|
451
|
-
}
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (relative.startsWith('src/resources/automations/')) {
|
|
455
|
-
for (const code of codes) {
|
|
456
|
-
inventory.automations.add(code);
|
|
457
|
-
addFingerprint(fingerprints.automations, code, file);
|
|
458
|
-
addManifestLocalSources(
|
|
459
|
-
fingerprints.automations,
|
|
460
|
-
code,
|
|
461
|
-
value,
|
|
462
|
-
relative
|
|
463
|
-
);
|
|
464
|
-
addDependencyForms('backend', `automation:${code}`, referencedForms);
|
|
465
|
-
}
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
if (relative.startsWith('src/resources/workflows/')) {
|
|
469
|
-
for (const code of codes) {
|
|
470
|
-
inventory.workflows.add(code);
|
|
471
|
-
addFingerprint(fingerprints.workflows, code, file);
|
|
472
|
-
addManifestLocalSources(
|
|
473
|
-
fingerprints.workflows,
|
|
474
|
-
code,
|
|
475
|
-
value,
|
|
476
|
-
relative
|
|
477
|
-
);
|
|
478
|
-
addDependencyForms('workflow', `workflow:${code}`, referencedForms);
|
|
479
|
-
}
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
const matched = Object.entries(CONFIG_RESOURCE_TYPES).find(([prefix]) =>
|
|
483
|
-
relative.startsWith(prefix)
|
|
484
|
-
);
|
|
485
|
-
if (matched) {
|
|
486
|
-
const type = matched[1];
|
|
487
|
-
for (const code of collectConfigurationManifestCodes(type, value)) {
|
|
488
|
-
addConfiguration(type, code);
|
|
489
|
-
addFingerprint(configurationFingerprintBucket(type), code, file);
|
|
490
|
-
addDependencyForms(
|
|
491
|
-
'configuration',
|
|
492
|
-
`${type}:${code}`,
|
|
493
|
-
referencedForms
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
if (type === 'form-permission-group') {
|
|
497
|
-
for (const dependency of collectFormPermissionGroupDependencies(value)) {
|
|
498
|
-
if (!formPermissionGroupForms.has(dependency.code)) {
|
|
499
|
-
formPermissionGroupForms.set(dependency.code, new Set());
|
|
500
|
-
}
|
|
501
|
-
formPermissionGroupForms
|
|
502
|
-
.get(dependency.code)
|
|
503
|
-
.add(dependency.formCode);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
// Automation source directories may contain shared TypeScript helpers such
|
|
509
|
-
// as src/automations/_shared. Only a resource manifest declares a deployable
|
|
510
|
-
// automation; source files belonging to a declared code still participate in
|
|
511
|
-
// that automation's fingerprint and transitive dependency expansion.
|
|
512
|
-
for (const code of inventory.automations) {
|
|
513
|
-
for (const file of automationSourceFilesByCode.get(code) || []) {
|
|
514
|
-
addFingerprint(fingerprints.automations, code, file);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
for (const bucket of [
|
|
518
|
-
fingerprints.forms,
|
|
519
|
-
fingerprints.functions,
|
|
520
|
-
fingerprints.automations,
|
|
521
|
-
fingerprints.workflows,
|
|
522
|
-
]) {
|
|
523
|
-
expandFingerprintDependencies(bucket, filesByPath, addFingerprint);
|
|
524
|
-
}
|
|
525
|
-
const serializeFingerprints = bucket =>
|
|
526
|
-
Object.fromEntries(
|
|
527
|
-
[...bucket.entries()]
|
|
528
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
529
|
-
.map(([code, entries]) => [
|
|
530
|
-
code,
|
|
531
|
-
sha256Canonical(
|
|
532
|
-
[...entries.entries()]
|
|
533
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
534
|
-
.map(([file, digest]) => ({ file, digest }))
|
|
535
|
-
),
|
|
536
|
-
])
|
|
537
|
-
);
|
|
538
|
-
const serializeDependencyMap = bucket =>
|
|
539
|
-
Object.fromEntries(
|
|
540
|
-
[...bucket.entries()]
|
|
541
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
542
|
-
.map(([owner, forms]) => [owner, [...forms].sort()])
|
|
543
|
-
);
|
|
544
|
-
const allDependencyForms = new Set(
|
|
545
|
-
Object.values(dependencyForms).flatMap(bucket =>
|
|
546
|
-
[...bucket.values()].flatMap(forms => [...forms])
|
|
547
|
-
)
|
|
548
|
-
);
|
|
549
|
-
const sharedFingerprints = Object.fromEntries(
|
|
550
|
-
['form', 'configuration', 'backend', 'workflow'].map(category => {
|
|
551
|
-
const assigned = assignedFingerprintPaths.get(category) || new Set();
|
|
552
|
-
const shared = files
|
|
553
|
-
.filter(file => file.category === category)
|
|
554
|
-
.filter(file => !assigned.has(file.relativePath))
|
|
555
|
-
.map(file => ({
|
|
556
|
-
file: file.relativePath,
|
|
557
|
-
digest: file.artifact.digest,
|
|
558
|
-
}));
|
|
559
|
-
return [category, sha256Canonical(shared)];
|
|
560
|
-
})
|
|
561
|
-
);
|
|
562
|
-
return {
|
|
563
|
-
forms: [...inventory.forms].sort(),
|
|
564
|
-
functions: [...inventory.functions].sort(),
|
|
565
|
-
automations: [...inventory.automations].sort(),
|
|
566
|
-
workflows: [...inventory.workflows].sort(),
|
|
567
|
-
configuration: Object.fromEntries(
|
|
568
|
-
[...inventory.configuration.entries()]
|
|
569
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
570
|
-
.map(([type, codes]) => [type, [...codes].sort()])
|
|
571
|
-
),
|
|
572
|
-
formDependencies: [...allDependencyForms].sort(),
|
|
573
|
-
formDependenciesByResource: {
|
|
574
|
-
configuration: serializeDependencyMap(dependencyForms.configuration),
|
|
575
|
-
backend: serializeDependencyMap(dependencyForms.backend),
|
|
576
|
-
workflow: serializeDependencyMap(dependencyForms.workflow),
|
|
577
|
-
},
|
|
578
|
-
formPermissionGroupForms: Object.fromEntries(
|
|
579
|
-
[...formPermissionGroupForms.entries()]
|
|
580
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
581
|
-
.map(([code, forms]) => [code, [...forms].sort()])
|
|
582
|
-
),
|
|
583
|
-
resourceFingerprints: {
|
|
584
|
-
forms: serializeFingerprints(fingerprints.forms),
|
|
585
|
-
functions: serializeFingerprints(fingerprints.functions),
|
|
586
|
-
automations: serializeFingerprints(fingerprints.automations),
|
|
587
|
-
workflows: serializeFingerprints(fingerprints.workflows),
|
|
588
|
-
configuration: Object.fromEntries(
|
|
589
|
-
[...fingerprints.configuration.entries()]
|
|
590
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
591
|
-
.map(([type, bucket]) => [type, serializeFingerprints(bucket)])
|
|
592
|
-
),
|
|
593
|
-
shared: sharedFingerprints,
|
|
594
|
-
},
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
function expandFingerprintDependencies(bucket, filesByPath, addFingerprint) {
|
|
599
|
-
for (const [code, entries] of bucket.entries()) {
|
|
600
|
-
const pending = [...entries.keys()];
|
|
601
|
-
const visited = new Set();
|
|
602
|
-
while (pending.length > 0) {
|
|
603
|
-
const relativePath = pending.shift();
|
|
604
|
-
if (visited.has(relativePath)) continue;
|
|
605
|
-
visited.add(relativePath);
|
|
606
|
-
const file = filesByPath.get(relativePath);
|
|
607
|
-
if (!file || !/\.(?:[cm]?js|tsx?)$/.test(relativePath)) continue;
|
|
608
|
-
for (const specifier of collectModuleSpecifiers(
|
|
609
|
-
file.artifact.buffer.toString('utf8')
|
|
610
|
-
)) {
|
|
611
|
-
const dependency = resolveLocalSourceDependency(
|
|
612
|
-
relativePath,
|
|
613
|
-
specifier,
|
|
614
|
-
filesByPath
|
|
615
|
-
);
|
|
616
|
-
if (!dependency) continue;
|
|
617
|
-
addFingerprint(bucket, code, dependency);
|
|
618
|
-
pending.push(dependency.relativePath);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
function collectLocalSourcePaths(value, result = new Set()) {
|
|
625
|
-
if (Array.isArray(value)) {
|
|
626
|
-
for (const item of value) collectLocalSourcePaths(item, result);
|
|
627
|
-
return [...result];
|
|
628
|
-
}
|
|
629
|
-
if (!value || typeof value !== 'object') return [...result];
|
|
630
|
-
for (const [key, child] of Object.entries(value)) {
|
|
631
|
-
if (
|
|
632
|
-
['localPath', 'sourcePath', 'definitionFile'].includes(key) &&
|
|
633
|
-
typeof child === 'string' &&
|
|
634
|
-
child.trim()
|
|
635
|
-
) {
|
|
636
|
-
result.add(child.trim());
|
|
637
|
-
} else if (child && typeof child === 'object') {
|
|
638
|
-
collectLocalSourcePaths(child, result);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return [...result];
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
function resolvePackagedSourceFile(localPath, manifestPath, filesByPath) {
|
|
645
|
-
const normalized = normalizePath(localPath);
|
|
646
|
-
const candidates = [
|
|
647
|
-
normalized,
|
|
648
|
-
path.posix.normalize(
|
|
649
|
-
path.posix.join(path.posix.dirname(manifestPath), normalized)
|
|
650
|
-
),
|
|
651
|
-
];
|
|
652
|
-
for (const candidate of candidates) {
|
|
653
|
-
if (filesByPath.has(candidate)) return filesByPath.get(candidate);
|
|
654
|
-
}
|
|
655
|
-
return null;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function collectModuleSpecifiers(source) {
|
|
659
|
-
const result = [];
|
|
660
|
-
const importPattern =
|
|
661
|
-
/(?:\bfrom\s*|\bimport\s*\(|\brequire\s*\(|\bimport\s+)\s*['"]([^'"]+)['"]/g;
|
|
662
|
-
let match;
|
|
663
|
-
while ((match = importPattern.exec(source))) {
|
|
664
|
-
const specifier = String(match[1] || '').trim();
|
|
665
|
-
if (specifier) result.push(specifier);
|
|
666
|
-
}
|
|
667
|
-
return result;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
function collectReferencedFormCodes(value, result = new Set()) {
|
|
671
|
-
if (Array.isArray(value)) {
|
|
672
|
-
for (const item of value) collectReferencedFormCodes(item, result);
|
|
673
|
-
return [...result];
|
|
674
|
-
}
|
|
675
|
-
if (!value || typeof value !== 'object') return [...result];
|
|
676
|
-
for (const key of ['formCode', 'sourceFormCode']) {
|
|
677
|
-
const code = normalizeResourceCode(value[key]);
|
|
678
|
-
if (code) result.add(code);
|
|
679
|
-
}
|
|
680
|
-
if (typeof value.form === 'string') {
|
|
681
|
-
const code = normalizeResourceCode(value.form);
|
|
682
|
-
if (code) result.add(code);
|
|
683
|
-
}
|
|
684
|
-
if (String(value.kind || '').trim() === 'form') {
|
|
685
|
-
const code = normalizeResourceCode(value.code || value.resourceCode);
|
|
686
|
-
if (code) result.add(code);
|
|
687
|
-
}
|
|
688
|
-
const declaredForms = value.resources?.forms;
|
|
689
|
-
if (Array.isArray(declaredForms)) {
|
|
690
|
-
for (const item of declaredForms) {
|
|
691
|
-
const code = normalizeResourceCode(item);
|
|
692
|
-
if (code) result.add(code);
|
|
693
|
-
}
|
|
694
|
-
} else if (declaredForms && typeof declaredForms === 'object') {
|
|
695
|
-
for (const key of Object.keys(declaredForms)) {
|
|
696
|
-
const code = normalizeResourceCode(key);
|
|
697
|
-
if (code) result.add(code);
|
|
698
|
-
}
|
|
699
|
-
} else {
|
|
700
|
-
const code = normalizeResourceCode(declaredForms);
|
|
701
|
-
if (code) result.add(code);
|
|
702
|
-
}
|
|
703
|
-
for (const child of Object.values(value)) {
|
|
704
|
-
if (child && typeof child === 'object') {
|
|
705
|
-
collectReferencedFormCodes(child, result);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
return [...result];
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
function collectFormPermissionGroupDependencies(value, result = []) {
|
|
712
|
-
if (Array.isArray(value)) {
|
|
713
|
-
for (const item of value) {
|
|
714
|
-
collectFormPermissionGroupDependencies(item, result);
|
|
715
|
-
}
|
|
716
|
-
return result;
|
|
717
|
-
}
|
|
718
|
-
if (!value || typeof value !== 'object') return result;
|
|
719
|
-
const code = normalizeResourceCode(value.code || value.resourceCode);
|
|
720
|
-
const formCode = normalizeResourceCode(value.formCode || value.form);
|
|
721
|
-
if (code && formCode) result.push({ code, formCode });
|
|
722
|
-
for (const child of Object.values(value)) {
|
|
723
|
-
if (child && typeof child === 'object') {
|
|
724
|
-
collectFormPermissionGroupDependencies(child, result);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
return result;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function normalizeResourceCode(value) {
|
|
731
|
-
const code = typeof value === 'string' ? value.trim() : '';
|
|
732
|
-
return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(code) ? code : '';
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function collectConfigurationManifestCodes(type, value) {
|
|
736
|
-
if (type !== 'data-view') return collectManifestCodes(value);
|
|
737
|
-
|
|
738
|
-
const result = new Set();
|
|
739
|
-
const addItem = item => {
|
|
740
|
-
if (!item || typeof item !== 'object' || Array.isArray(item)) return;
|
|
741
|
-
const code = String(item.code || item.resourceCode || '').trim();
|
|
742
|
-
if (code) result.add(code);
|
|
743
|
-
};
|
|
744
|
-
if (Array.isArray(value)) {
|
|
745
|
-
value.forEach(addItem);
|
|
746
|
-
return [...result];
|
|
747
|
-
}
|
|
748
|
-
if (!value || typeof value !== 'object') return [];
|
|
749
|
-
const rootCode = String(value.code || value.resourceCode || '').trim();
|
|
750
|
-
if (rootCode) {
|
|
751
|
-
result.add(rootCode);
|
|
752
|
-
return [...result];
|
|
753
|
-
}
|
|
754
|
-
for (const key of ['dataViews', 'data-views']) {
|
|
755
|
-
const items = value[key];
|
|
756
|
-
if (Array.isArray(items)) items.forEach(addItem);
|
|
757
|
-
else addItem(items);
|
|
758
|
-
}
|
|
759
|
-
return [...result];
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
function collectManifestCodes(value, result = new Set()) {
|
|
763
|
-
if (Array.isArray(value)) {
|
|
764
|
-
for (const item of value) collectManifestCodes(item, result);
|
|
765
|
-
return [...result];
|
|
766
|
-
}
|
|
767
|
-
if (!value || typeof value !== 'object') return [...result];
|
|
768
|
-
const code = String(
|
|
769
|
-
value.code ||
|
|
770
|
-
value.resourceCode ||
|
|
771
|
-
value.formCode ||
|
|
772
|
-
value.notificationType ||
|
|
773
|
-
''
|
|
774
|
-
).trim();
|
|
775
|
-
if (code) result.add(code);
|
|
776
|
-
for (const [key, child] of Object.entries(value)) {
|
|
777
|
-
if (
|
|
778
|
-
[
|
|
779
|
-
'definitionJson',
|
|
780
|
-
'schema',
|
|
781
|
-
'components',
|
|
782
|
-
'configJson',
|
|
783
|
-
'settings',
|
|
784
|
-
'grants',
|
|
785
|
-
].includes(key)
|
|
786
|
-
) {
|
|
787
|
-
continue;
|
|
788
|
-
}
|
|
789
|
-
if (Array.isArray(child)) collectManifestCodes(child, result);
|
|
790
|
-
}
|
|
791
|
-
return [...result];
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
function buildAuthoredLayer(kind, files, previousLayer) {
|
|
795
|
-
const selected =
|
|
796
|
-
kind === 'source'
|
|
797
|
-
? files
|
|
798
|
-
: files.filter(file => file.category === kind);
|
|
799
|
-
if (selected.length === 0 && kind !== 'source') return null;
|
|
800
|
-
const sourceHash = sourceHashForCategory(files, kind);
|
|
801
|
-
if (
|
|
802
|
-
previousLayer &&
|
|
803
|
-
previousLayer.sourceHash === sourceHash &&
|
|
804
|
-
previousLayer.digest
|
|
805
|
-
) {
|
|
806
|
-
return {
|
|
807
|
-
descriptor: previousLayer,
|
|
808
|
-
artifacts: [],
|
|
809
|
-
reused: true,
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
const manifest = {
|
|
813
|
-
schemaVersion: 'openxiangda-app-layer-v2',
|
|
814
|
-
kind,
|
|
815
|
-
sourceHash,
|
|
816
|
-
files: selected.map(file => file.descriptor),
|
|
817
|
-
};
|
|
818
|
-
const manifestBuffer = Buffer.from(canonicalJson(manifest));
|
|
819
|
-
const layerArtifact = artifactFromBuffer(kind, manifestBuffer, {
|
|
820
|
-
layer: kind,
|
|
821
|
-
contentType: 'application/json',
|
|
822
|
-
});
|
|
823
|
-
return {
|
|
824
|
-
descriptor: {
|
|
825
|
-
kind,
|
|
826
|
-
digest: layerArtifact.digest,
|
|
827
|
-
sourceHash,
|
|
828
|
-
fileCount: selected.length,
|
|
829
|
-
size: selected.reduce((sum, file) => sum + file.artifact.size, 0),
|
|
830
|
-
files: manifest.files,
|
|
831
|
-
},
|
|
832
|
-
artifacts: [
|
|
833
|
-
...selected.map(file => file.artifact),
|
|
834
|
-
layerArtifact,
|
|
835
|
-
],
|
|
836
|
-
reused: false,
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
async function buildRuntimeLayer(options, files, previousLayer) {
|
|
841
|
-
const sourceHash = sourceHashForCategory(files, 'runtime');
|
|
842
|
-
if (
|
|
843
|
-
previousLayer &&
|
|
844
|
-
previousLayer.sourceHash === sourceHash &&
|
|
845
|
-
previousLayer.digest
|
|
846
|
-
) {
|
|
847
|
-
return {
|
|
848
|
-
descriptor: previousLayer,
|
|
849
|
-
artifacts: [],
|
|
850
|
-
reused: true,
|
|
851
|
-
built: false,
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
if (!options.skipBuild) {
|
|
855
|
-
await runBuild({
|
|
856
|
-
workspaceRoot: options.workspaceRoot,
|
|
857
|
-
command: options.buildCommand || 'npm run build',
|
|
858
|
-
env: {
|
|
859
|
-
OPENXIANGDA_APP_TYPE: '__OPENXIANGDA_APP_TYPE__',
|
|
860
|
-
APP_TYPE: '__OPENXIANGDA_APP_TYPE__',
|
|
861
|
-
OPENXIANGDA_BUILD_ID: `pkg-${sourceHash.slice(0, 20)}`,
|
|
862
|
-
OPENXIANGDA_RUNTIME_ASSET_BASE: './',
|
|
863
|
-
},
|
|
864
|
-
onOutput: options.onBuildOutput,
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
const distDir = path.resolve(
|
|
868
|
-
options.workspaceRoot,
|
|
869
|
-
options.distDir || 'dist'
|
|
870
|
-
);
|
|
871
|
-
const runtimeFiles = collectRuntimeFiles(distDir);
|
|
872
|
-
const runtimeArtifacts = runtimeFiles.map(file =>
|
|
873
|
-
artifactFromBuffer('runtime', file.buffer, {
|
|
874
|
-
path: file.path,
|
|
875
|
-
contentType: file.contentType,
|
|
876
|
-
})
|
|
877
|
-
);
|
|
878
|
-
const descriptors = runtimeArtifacts.map((artifact, index) =>
|
|
879
|
-
fileDescriptor(artifact, runtimeFiles[index].path)
|
|
880
|
-
);
|
|
881
|
-
const manifest = {
|
|
882
|
-
schemaVersion: 'openxiangda-app-layer-v2',
|
|
883
|
-
kind: 'runtime',
|
|
884
|
-
sourceHash,
|
|
885
|
-
assetBaseMode: 'relative',
|
|
886
|
-
files: descriptors,
|
|
887
|
-
};
|
|
888
|
-
const layerArtifact = artifactFromBuffer(
|
|
889
|
-
'runtime',
|
|
890
|
-
Buffer.from(canonicalJson(manifest)),
|
|
891
|
-
{
|
|
892
|
-
layer: 'runtime',
|
|
893
|
-
contentType: 'application/json',
|
|
894
|
-
}
|
|
895
|
-
);
|
|
896
|
-
return {
|
|
897
|
-
descriptor: {
|
|
898
|
-
kind: 'runtime',
|
|
899
|
-
digest: layerArtifact.digest,
|
|
900
|
-
sourceHash,
|
|
901
|
-
assetBaseMode: 'relative',
|
|
902
|
-
fileCount: descriptors.length,
|
|
903
|
-
size: runtimeArtifacts.reduce((sum, artifact) => sum + artifact.size, 0),
|
|
904
|
-
files: descriptors,
|
|
905
|
-
},
|
|
906
|
-
artifacts: [...runtimeArtifacts, layerArtifact],
|
|
907
|
-
reused: false,
|
|
908
|
-
built: !options.skipBuild,
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
async function compileAppPackage(options = {}) {
|
|
913
|
-
const workspaceRoot = path.resolve(options.workspaceRoot || process.cwd());
|
|
914
|
-
const configFile = path.join(workspaceRoot, 'app-workspace.config.ts');
|
|
915
|
-
if (!fs.existsSync(configFile)) {
|
|
916
|
-
throw createCompilerError(
|
|
917
|
-
'DELIVERY_WORKSPACE_CONFIG_MISSING',
|
|
918
|
-
`未发现 ${configFile}`
|
|
919
|
-
);
|
|
920
|
-
}
|
|
921
|
-
const configText = fs.readFileSync(configFile, 'utf8');
|
|
922
|
-
if (!/deliveryVersion\s*:\s*2\b/.test(configText)) {
|
|
923
|
-
throw createCompilerError(
|
|
924
|
-
'DELIVERY_V2_NOT_ENABLED',
|
|
925
|
-
'app-workspace.config.ts 必须显式声明 deliveryVersion: 2'
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
|
-
const runtimeEnabled =
|
|
929
|
-
/runtimeMode\s*:\s*['"]react-spa['"]/.test(configText);
|
|
930
|
-
const files = sourceArtifacts(workspaceRoot);
|
|
931
|
-
const previousManifest = options.previousManifest || null;
|
|
932
|
-
const previousLayers = new Map(
|
|
933
|
-
(previousManifest?.layers || []).map(layer => [layer.kind, layer])
|
|
934
|
-
);
|
|
935
|
-
const artifacts = [];
|
|
936
|
-
const layerResults = [];
|
|
937
|
-
const resources = discoverResourceInventory(workspaceRoot, files);
|
|
938
|
-
const buildClosure = collectUnsealedBuildDependencies(files);
|
|
939
|
-
if (buildClosure.missingLocalDependencies.length > 0) {
|
|
940
|
-
throw createCompilerError(
|
|
941
|
-
'DELIVERY_BUILD_LOCAL_DEPENDENCY_MISSING',
|
|
942
|
-
`Form/Backend/Workflow 源码引用了未进入 App Package 的本地文件: ${buildClosure.missingLocalDependencies.join(', ')}`
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
if (buildClosure.externalPackages.length > 0) {
|
|
946
|
-
throw createCompilerError(
|
|
947
|
-
'DELIVERY_BUILD_DEPENDENCY_NOT_SEALED',
|
|
948
|
-
`Form/Backend/Workflow 源码引用了未进入密封工具链的包: ${buildClosure.externalPackages.join(', ')}。请改为 OpenXiangda 公共 SDK、本地源码依赖,或先扩展 Delivery V2 dependency layer。`
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
for (const kind of ['source', 'form', 'configuration', 'backend', 'workflow']) {
|
|
953
|
-
const result = buildAuthoredLayer(
|
|
954
|
-
kind,
|
|
955
|
-
files,
|
|
956
|
-
previousLayers.get(kind)
|
|
957
|
-
);
|
|
958
|
-
if (!result) continue;
|
|
959
|
-
artifacts.push(...result.artifacts);
|
|
960
|
-
layerResults.push(result);
|
|
961
|
-
}
|
|
962
|
-
if (runtimeEnabled) {
|
|
963
|
-
const runtimeResult = await buildRuntimeLayer(
|
|
964
|
-
{ ...options, workspaceRoot },
|
|
965
|
-
files,
|
|
966
|
-
previousLayers.get('runtime')
|
|
967
|
-
);
|
|
968
|
-
artifacts.push(...runtimeResult.artifacts);
|
|
969
|
-
layerResults.push(runtimeResult);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
const layers = LAYER_ORDER.map(kind =>
|
|
973
|
-
layerResults.find(result => result.descriptor.kind === kind)
|
|
974
|
-
)
|
|
975
|
-
.filter(Boolean)
|
|
976
|
-
.map(result => result.descriptor);
|
|
977
|
-
const packageManifest = {
|
|
978
|
-
schemaVersion: PACKAGE_SCHEMA_VERSION,
|
|
979
|
-
compilerVersion: COMPILER_VERSION,
|
|
980
|
-
mode: 'trusted-developer',
|
|
981
|
-
runtimeMode: runtimeEnabled ? 'react-spa' : 'legacy',
|
|
982
|
-
buildRequirements: {
|
|
983
|
-
contractVersion: 'delivery_v2_build_closure_v1',
|
|
984
|
-
sealed: true,
|
|
985
|
-
runtime: runtimeEnabled ? 'prebuilt-runtime-layer' : 'not-required',
|
|
986
|
-
authoredResources: 'openxiangda-bundled-toolchain',
|
|
987
|
-
workspaceNodeModules: 'forbidden',
|
|
988
|
-
externalPackages: [],
|
|
989
|
-
},
|
|
990
|
-
resources,
|
|
991
|
-
layers,
|
|
992
|
-
};
|
|
993
|
-
const packageBuffer = Buffer.from(canonicalJson(packageManifest));
|
|
994
|
-
const packageArtifact = artifactFromBuffer(
|
|
995
|
-
'package-manifest',
|
|
996
|
-
packageBuffer,
|
|
997
|
-
{
|
|
998
|
-
contentType: 'application/json',
|
|
999
|
-
schemaVersion: PACKAGE_SCHEMA_VERSION,
|
|
1000
|
-
}
|
|
1001
|
-
);
|
|
1002
|
-
artifacts.push(packageArtifact);
|
|
1003
|
-
|
|
1004
|
-
return {
|
|
1005
|
-
workspaceRoot,
|
|
1006
|
-
packageDigest: packageArtifact.digest,
|
|
1007
|
-
packageManifest,
|
|
1008
|
-
artifacts: deduplicateArtifacts(artifacts),
|
|
1009
|
-
summary: {
|
|
1010
|
-
sourceFileCount: files.length,
|
|
1011
|
-
artifactUploadCount: deduplicateArtifacts(artifacts).length,
|
|
1012
|
-
layers: layerResults.map(result => ({
|
|
1013
|
-
kind: result.descriptor.kind,
|
|
1014
|
-
digest: result.descriptor.digest,
|
|
1015
|
-
sourceHash: result.descriptor.sourceHash,
|
|
1016
|
-
reused: result.reused,
|
|
1017
|
-
built: Boolean(result.built),
|
|
1018
|
-
fileCount: result.descriptor.fileCount,
|
|
1019
|
-
size: result.descriptor.size,
|
|
1020
|
-
})),
|
|
1021
|
-
},
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
function deduplicateArtifacts(artifacts) {
|
|
1026
|
-
const byDigest = new Map();
|
|
1027
|
-
for (const artifact of artifacts) {
|
|
1028
|
-
if (!byDigest.has(artifact.digest)) byDigest.set(artifact.digest, artifact);
|
|
1029
|
-
}
|
|
1030
|
-
return [...byDigest.values()];
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
function collectRuntimeFiles(distDir) {
|
|
1034
|
-
if (!fs.existsSync(distDir) || !fs.statSync(distDir).isDirectory()) {
|
|
1035
|
-
throw createCompilerError(
|
|
1036
|
-
'DELIVERY_RUNTIME_DIST_MISSING',
|
|
1037
|
-
`Runtime dist 目录不存在: ${distDir}`
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
const files = [];
|
|
1041
|
-
const visit = currentDir => {
|
|
1042
|
-
const entries = fs
|
|
1043
|
-
.readdirSync(currentDir, { withFileTypes: true })
|
|
1044
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
1045
|
-
for (const entry of entries) {
|
|
1046
|
-
const absolute = path.join(currentDir, entry.name);
|
|
1047
|
-
if (entry.isDirectory()) {
|
|
1048
|
-
visit(absolute);
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
if (!entry.isFile() || entry.name.endsWith('.map')) continue;
|
|
1052
|
-
const relative = normalizePath(path.relative(distDir, absolute));
|
|
1053
|
-
const buffer = fs.readFileSync(absolute);
|
|
1054
|
-
files.push({
|
|
1055
|
-
path: relative,
|
|
1056
|
-
buffer,
|
|
1057
|
-
contentType: inferContentType(relative),
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
visit(distDir);
|
|
1062
|
-
if (!files.some(file => file.path === 'index.html')) {
|
|
1063
|
-
throw createCompilerError(
|
|
1064
|
-
'DELIVERY_RUNTIME_INDEX_MISSING',
|
|
1065
|
-
`Runtime dist 缺少 index.html: ${distDir}`
|
|
1066
|
-
);
|
|
1067
|
-
}
|
|
1068
|
-
const totalBytes = files.reduce((sum, file) => sum + file.buffer.length, 0);
|
|
1069
|
-
if (totalBytes > MAX_RUNTIME_BYTES) {
|
|
1070
|
-
throw createCompilerError(
|
|
1071
|
-
'DELIVERY_RUNTIME_TOO_LARGE',
|
|
1072
|
-
`Runtime dist 超过 ${MAX_RUNTIME_BYTES} bytes`
|
|
1073
|
-
);
|
|
1074
|
-
}
|
|
1075
|
-
return files;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
async function runBuild(options) {
|
|
1079
|
-
await new Promise((resolve, reject) => {
|
|
1080
|
-
let child;
|
|
1081
|
-
try {
|
|
1082
|
-
child = spawn(options.command, [], {
|
|
1083
|
-
cwd: options.workspaceRoot,
|
|
1084
|
-
shell: true,
|
|
1085
|
-
stdio: options.onOutput ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
1086
|
-
env: {
|
|
1087
|
-
...process.env,
|
|
1088
|
-
...options.env,
|
|
1089
|
-
},
|
|
1090
|
-
});
|
|
1091
|
-
} catch (error) {
|
|
1092
|
-
reject(
|
|
1093
|
-
createCompilerError(
|
|
1094
|
-
'DELIVERY_RUNTIME_BUILD_START_FAILED',
|
|
1095
|
-
error?.message || String(error)
|
|
1096
|
-
)
|
|
1097
|
-
);
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
if (options.onOutput) {
|
|
1101
|
-
child.stdout?.on('data', chunk =>
|
|
1102
|
-
options.onOutput('stdout', String(chunk))
|
|
1103
|
-
);
|
|
1104
|
-
child.stderr?.on('data', chunk =>
|
|
1105
|
-
options.onOutput('stderr', String(chunk))
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
child.once('error', error => {
|
|
1109
|
-
reject(
|
|
1110
|
-
createCompilerError(
|
|
1111
|
-
'DELIVERY_RUNTIME_BUILD_START_FAILED',
|
|
1112
|
-
error.message
|
|
1113
|
-
)
|
|
1114
|
-
);
|
|
1115
|
-
});
|
|
1116
|
-
child.once('close', (code, signal) => {
|
|
1117
|
-
if (code === 0) {
|
|
1118
|
-
resolve();
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
reject(
|
|
1122
|
-
createCompilerError(
|
|
1123
|
-
'DELIVERY_RUNTIME_BUILD_FAILED',
|
|
1124
|
-
Number.isInteger(code)
|
|
1125
|
-
? `exit ${code}`
|
|
1126
|
-
: `signal ${signal || 'unknown'}`
|
|
1127
|
-
)
|
|
1128
|
-
);
|
|
1129
|
-
});
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
function inferContentType(file) {
|
|
1134
|
-
const extension = path.extname(file).toLowerCase();
|
|
1135
|
-
return (
|
|
1136
|
-
{
|
|
1137
|
-
'.css': 'text/css; charset=utf-8',
|
|
1138
|
-
'.html': 'text/html; charset=utf-8',
|
|
1139
|
-
'.ico': 'image/x-icon',
|
|
1140
|
-
'.jpeg': 'image/jpeg',
|
|
1141
|
-
'.jpg': 'image/jpeg',
|
|
1142
|
-
'.js': 'text/javascript; charset=utf-8',
|
|
1143
|
-
'.json': 'application/json',
|
|
1144
|
-
'.mjs': 'text/javascript; charset=utf-8',
|
|
1145
|
-
'.png': 'image/png',
|
|
1146
|
-
'.svg': 'image/svg+xml',
|
|
1147
|
-
'.ts': 'text/plain; charset=utf-8',
|
|
1148
|
-
'.tsx': 'text/plain; charset=utf-8',
|
|
1149
|
-
'.txt': 'text/plain; charset=utf-8',
|
|
1150
|
-
'.webp': 'image/webp',
|
|
1151
|
-
'.woff': 'font/woff',
|
|
1152
|
-
'.woff2': 'font/woff2',
|
|
1153
|
-
}[extension] || 'application/octet-stream'
|
|
1154
|
-
);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
function createCompilerError(code, message) {
|
|
1158
|
-
const error = new Error(`${code}: ${message}`);
|
|
1159
|
-
error.code = code;
|
|
1160
|
-
error.retryable = false;
|
|
1161
|
-
return error;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
module.exports = {
|
|
1165
|
-
COMPILER_VERSION,
|
|
1166
|
-
PACKAGE_SCHEMA_VERSION,
|
|
1167
|
-
canonicalJson,
|
|
1168
|
-
collectConfigurationManifestCodes,
|
|
1169
|
-
collectManifestCodes,
|
|
1170
|
-
compileAppPackage,
|
|
1171
|
-
discoverResourceInventory,
|
|
1172
|
-
layerForSourceFile,
|
|
1173
|
-
sha256,
|
|
1174
|
-
sha256Canonical,
|
|
1175
|
-
shouldIncludeSourceFile,
|
|
1176
|
-
};
|