@tailor-platform/sdk 1.72.0 → 1.73.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/CHANGELOG.md +42 -0
- package/dist/aigateway-B3oZZE6v.mjs +15 -0
- package/dist/aigateway-B3oZZE6v.mjs.map +1 -0
- package/dist/application-BXdCl6bp.mjs +3 -0
- package/dist/{application-DmjIKQ-a.mjs → application-Bb9NNp5m.mjs} +54 -28
- package/dist/application-Bb9NNp5m.mjs.map +1 -0
- package/dist/{assert-CKfwrmCV.mjs → assert-DBxo8jPo.mjs} +1 -2
- package/dist/{assert-CKfwrmCV.mjs.map → assert-DBxo8jPo.mjs.map} +1 -1
- package/dist/{authconnection-D7lsvsKY.mjs → authconnection-BGQM8FZI.mjs} +2 -3
- package/dist/{authconnection-D7lsvsKY.mjs.map → authconnection-BGQM8FZI.mjs.map} +1 -1
- package/dist/{brand-DlnJ375c.mjs → brand-Eo4pLXPJ.mjs} +1 -2
- package/dist/{brand-DlnJ375c.mjs.map → brand-Eo4pLXPJ.mjs.map} +1 -1
- package/dist/cli/cache/bundle-cache.d.mts +1 -0
- package/dist/cli/cache/store.d.mts +1 -0
- package/dist/cli/cache/types.d.mts +1 -0
- package/dist/cli/commands/api/api-call.d.mts +19 -0
- package/dist/cli/commands/api/index.d.mts +3 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +1 -0
- package/dist/cli/commands/deploy/application.d.mts +1 -0
- package/dist/cli/commands/deploy/auth.d.mts +1 -0
- package/dist/cli/commands/deploy/deploy.d.mts +24 -0
- package/dist/cli/commands/deploy/executor.d.mts +1 -0
- package/dist/cli/commands/deploy/function-registry-types.d.mts +12 -0
- package/dist/cli/commands/deploy/function-registry.d.mts +2 -0
- package/dist/cli/commands/deploy/idp.d.mts +1 -0
- package/dist/cli/commands/deploy/resolver.d.mts +1 -0
- package/dist/cli/commands/deploy/secret-manager.d.mts +1 -0
- package/dist/cli/commands/deploy/staticwebsite.d.mts +1 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +1 -0
- package/dist/cli/commands/deploy/types.d.mts +1 -0
- package/dist/cli/commands/deploy/workflow.d.mts +1 -0
- package/dist/cli/commands/executor/get.d.mts +29 -0
- package/dist/cli/commands/executor/jobs.d.mts +123 -0
- package/dist/cli/commands/executor/list.d.mts +19 -0
- package/dist/cli/commands/executor/transform.d.mts +41 -0
- package/dist/cli/commands/executor/trigger.d.mts +41 -0
- package/dist/cli/commands/executor/webhook.d.mts +22 -0
- package/dist/cli/commands/function/get.d.mts +18 -0
- package/dist/cli/commands/function/list.d.mts +22 -0
- package/dist/cli/commands/function/transform.d.mts +11 -0
- package/dist/cli/commands/generate/options.d.mts +7 -0
- package/dist/cli/commands/generate/seed/bundler.d.mts +26 -0
- package/dist/cli/commands/generate/service.d.mts +12 -0
- package/dist/cli/commands/generate/types.d.mts +126 -0
- package/dist/cli/commands/machineuser/list.d.mts +27 -0
- package/dist/cli/commands/machineuser/token.d.mts +22 -0
- package/dist/cli/commands/oauth2client/get.d.mts +18 -0
- package/dist/cli/commands/oauth2client/list.d.mts +20 -0
- package/dist/cli/commands/oauth2client/transform.d.mts +20 -0
- package/dist/cli/commands/organization/folder/create.d.mts +18 -0
- package/dist/cli/commands/organization/folder/delete.d.mts +16 -0
- package/dist/cli/commands/organization/folder/get.d.mts +17 -0
- package/dist/cli/commands/organization/folder/list.d.mts +22 -0
- package/dist/cli/commands/organization/folder/update.d.mts +18 -0
- package/dist/cli/commands/organization/get.d.mts +16 -0
- package/dist/cli/commands/organization/list.d.mts +15 -0
- package/dist/cli/commands/organization/transform.d.mts +27 -0
- package/dist/cli/commands/organization/tree.d.mts +25 -0
- package/dist/cli/commands/organization/update.d.mts +17 -0
- package/dist/cli/commands/remove.d.mts +16 -0
- package/dist/cli/commands/show.d.mts +34 -0
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +28 -0
- package/dist/cli/commands/tailordb/migrate/config.d.mts +19 -0
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +223 -0
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +17 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +202 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +113 -0
- package/dist/cli/commands/tailordb/migrate/types.d.mts +7 -0
- package/dist/cli/commands/tailordb/truncate.d.mts +19 -0
- package/dist/cli/commands/workflow/executions.d.mts +75 -0
- package/dist/cli/commands/workflow/get.d.mts +29 -0
- package/dist/cli/commands/workflow/list.d.mts +19 -0
- package/dist/cli/commands/workflow/resume.d.mts +23 -0
- package/dist/cli/commands/workflow/start.d.mts +63 -0
- package/dist/cli/commands/workflow/status.d.mts +5 -0
- package/dist/cli/commands/workflow/transform.d.mts +33 -0
- package/dist/cli/commands/workflow/wait.d.mts +16 -0
- package/dist/cli/commands/workflow/waiter.d.mts +23 -0
- package/dist/cli/commands/workspace/app/health.d.mts +18 -0
- package/dist/cli/commands/workspace/app/list.d.mts +22 -0
- package/dist/cli/commands/workspace/app/transform.d.mts +18 -0
- package/dist/cli/commands/workspace/create.d.mts +25 -0
- package/dist/cli/commands/workspace/delete.d.mts +15 -0
- package/dist/cli/commands/workspace/get.d.mts +17 -0
- package/dist/cli/commands/workspace/list.d.mts +17 -0
- package/dist/cli/commands/workspace/restore.d.mts +15 -0
- package/dist/cli/commands/workspace/transform.d.mts +16 -0
- package/dist/cli/commands/workspace/user/invite.d.mts +22 -0
- package/dist/cli/commands/workspace/user/list.d.mts +22 -0
- package/dist/cli/commands/workspace/user/remove.d.mts +17 -0
- package/dist/cli/commands/workspace/user/transform.d.mts +8 -0
- package/dist/cli/commands/workspace/user/update.d.mts +22 -0
- package/dist/cli/index.d.mts +1 -2
- package/dist/cli/index.mjs +24 -25
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +80 -21402
- package/dist/cli/lib.mjs +8 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/query/index.d.mts +35 -0
- package/dist/cli/services/application.d.mts +1 -0
- package/dist/cli/services/auth/service.d.mts +1 -0
- package/dist/cli/services/executor/service.d.mts +1 -0
- package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
- package/dist/cli/services/http-adapter/service.d.mts +1 -0
- package/dist/cli/services/resolver/service.d.mts +1 -0
- package/dist/cli/services/tailordb/service.d.mts +1 -0
- package/dist/cli/services/workflow/bundler.d.mts +1 -0
- package/dist/cli/services/workflow/service.d.mts +1 -0
- package/dist/cli/shared/args.d.mts +13 -0
- package/dist/cli/shared/client.d.mts +1273 -0
- package/dist/cli/shared/config-loader.d.mts +44 -0
- package/dist/cli/shared/context.d.mts +28 -0
- package/dist/cli/shared/script-executor.d.mts +74 -0
- package/dist/cli/shared/seed-chunker.d.mts +46 -0
- package/dist/cli/shared/trigger-context.d.mts +1 -0
- package/dist/cli/shared/type-generator.d.mts +20 -0
- package/dist/cli/skills.mjs +1 -2
- package/dist/cli/skills.mjs.map +1 -1
- package/dist/completion/zsh-worker.zsh +1 -1
- package/dist/configure/config/index.d.mts +29 -0
- package/dist/configure/config/types.d.mts +103 -0
- package/dist/configure/index.d.mts +125 -7
- package/dist/configure/index.mjs +5 -6
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +17 -0
- package/dist/configure/services/aigateway/types.d.mts +11 -0
- package/dist/configure/services/auth/index.d.mts +43 -0
- package/dist/{types-v_ErzNUF.d.mts → configure/services/auth/types.d.mts} +7 -172
- package/dist/configure/services/executor/executor.d.mts +82 -0
- package/dist/configure/services/executor/index.d.mts +8 -0
- package/dist/configure/services/executor/operation.d.mts +46 -0
- package/dist/configure/services/executor/trigger/event.d.mts +272 -0
- package/dist/configure/services/executor/trigger/index.d.mts +8 -0
- package/dist/configure/services/executor/trigger/schedule.d.mts +25 -0
- package/dist/configure/services/executor/trigger/webhook.d.mts +44 -0
- package/dist/configure/services/executor/types.d.mts +2 -0
- package/dist/configure/services/http-adapter/http-adapter.d.mts +125 -0
- package/dist/configure/services/http-adapter/index.d.mts +2 -0
- package/dist/configure/services/idp/index.d.mts +64 -0
- package/dist/configure/services/idp/permission.d.mts +80 -0
- package/dist/configure/services/idp/types.d.mts +20 -0
- package/dist/configure/services/index.d.mts +33 -0
- package/dist/configure/services/resolver/index.d.mts +5 -0
- package/dist/configure/services/resolver/resolver.d.mts +77 -0
- package/dist/configure/services/resolver/types.d.mts +6 -0
- package/dist/configure/services/secrets/index.d.mts +38 -0
- package/dist/configure/services/secrets/types.d.mts +11 -0
- package/dist/configure/services/staticwebsite/index.d.mts +19 -0
- package/dist/configure/services/staticwebsite/types.d.mts +11 -0
- package/dist/configure/services/tailordb/index.d.mts +4 -0
- package/dist/configure/services/tailordb/permission.d.mts +119 -0
- package/dist/configure/services/tailordb/schema.d.mts +451 -0
- package/dist/configure/services/tailordb/types.d.mts +149 -0
- package/dist/configure/services/workflow/index.d.mts +7 -0
- package/dist/configure/services/workflow/job.d.mts +81 -0
- package/dist/configure/services/workflow/test-env-key.d.mts +9 -0
- package/dist/configure/services/workflow/types.d.mts +2 -0
- package/dist/configure/services/workflow/wait-point.d.mts +73 -0
- package/dist/configure/services/workflow/workflow.d.mts +55 -0
- package/dist/configure/types/aigateway-name.d.mts +12 -0
- package/dist/configure/types/connection-name.d.mts +12 -0
- package/dist/configure/types/field.d.mts +9 -0
- package/dist/configure/types/field.types.d.mts +109 -0
- package/dist/configure/types/idp-name.d.mts +12 -0
- package/dist/configure/types/index.d.mts +4 -0
- package/dist/configure/types/machine-user.d.mts +12 -0
- package/dist/configure/types/type.d.mts +99 -0
- package/dist/configure/user.d.mts +7 -0
- package/dist/{context-CDQqIv4u.mjs → context-Bd266-ru.mjs} +2 -3
- package/dist/{context-CDQqIv4u.mjs.map → context-Bd266-ru.mjs.map} +1 -1
- package/dist/{crashreport-BwF8cHF0.mjs → crashreport-Dy4ZzSkd.mjs} +1 -2
- package/dist/{crashreport-BqyvFk-_.mjs → crashreport-ayWANEZ6.mjs} +4 -5
- package/dist/{crashreport-BqyvFk-_.mjs.map → crashreport-ayWANEZ6.mjs.map} +1 -1
- package/dist/{enum-constants-C7DaWeQo.mjs → enum-constants-j9QBF0cB.mjs} +1 -2
- package/dist/{enum-constants-C7DaWeQo.mjs.map → enum-constants-j9QBF0cB.mjs.map} +1 -1
- package/dist/{errors-EsY4XO6O.mjs → errors-Dtf2WPaW.mjs} +1 -2
- package/dist/{errors-EsY4XO6O.mjs.map → errors-Dtf2WPaW.mjs.map} +1 -1
- package/dist/{field-C4zdJLW5.mjs → field-DOsJCPFa.mjs} +1 -2
- package/dist/{field-C4zdJLW5.mjs.map → field-DOsJCPFa.mjs.map} +1 -1
- package/dist/{file-BkxupbYP.mjs → file-_oUZo76X.mjs} +2 -3
- package/dist/{file-BkxupbYP.mjs.map → file-_oUZo76X.mjs.map} +1 -1
- package/dist/{file-utils-BHPxPXmn.mjs → file-utils-DcyIPFQh.mjs} +2 -3
- package/dist/{file-utils-BHPxPXmn.mjs.map → file-utils-DcyIPFQh.mjs.map} +1 -1
- package/dist/{globals-ByrCoDip.mjs → globals-B8XX5TRB.mjs} +3 -3
- package/dist/globals-B8XX5TRB.mjs.map +1 -0
- package/dist/{iconv-D1zmPjvi.mjs → iconv-D2vi8G36.mjs} +2 -3
- package/dist/{iconv-D1zmPjvi.mjs.map → iconv-D2vi8G36.mjs.map} +1 -1
- package/dist/{idp-ynUfzwpz.mjs → idp-Bx25ZBdN.mjs} +2 -3
- package/dist/{idp-ynUfzwpz.mjs.map → idp-Bx25ZBdN.mjs.map} +1 -1
- package/dist/{interceptor-DOqRkCya.mjs → interceptor-D-q1rvRl.mjs} +1 -2
- package/dist/{interceptor-DOqRkCya.mjs.map → interceptor-D-q1rvRl.mjs.map} +1 -1
- package/dist/{job-BpsFXPbi.mjs → job-CtU73PGa.mjs} +3 -4
- package/dist/job-CtU73PGa.mjs.map +1 -0
- package/dist/kysely/index.d.mts +2 -3
- package/dist/kysely/index.mjs +0 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{kysely-type-CSoZxVKN.mjs → kysely-type-D-zflMGf.mjs} +2 -3
- package/dist/{kysely-type-CSoZxVKN.mjs.map → kysely-type-D-zflMGf.mjs.map} +1 -1
- package/dist/{logger-DKF-JsAK.mjs → logger-BEiZZ3qT.mjs} +1 -2
- package/dist/{logger-DKF-JsAK.mjs.map → logger-BEiZZ3qT.mjs.map} +1 -1
- package/dist/{mock-wf5qeZLi.mjs → mock-Ce1GCi4-.mjs} +60 -5
- package/dist/mock-Ce1GCi4-.mjs.map +1 -0
- package/dist/{multiline-Cf9ODpr1.mjs → multiline-sfHpTZZK.mjs} +1 -2
- package/dist/{multiline-Cf9ODpr1.mjs.map → multiline-sfHpTZZK.mjs.map} +1 -1
- package/dist/{package-json-DcQApfPQ.mjs → package-json-8b0O9TlX.mjs} +1 -2
- package/dist/{package-json-DcQApfPQ.mjs.map → package-json-8b0O9TlX.mjs.map} +1 -1
- package/dist/package-json-Cv2Z-TqQ.mjs +3 -0
- package/dist/parser/generator-config/schema.d.mts +1 -0
- package/dist/parser/service/auth/index.d.mts +1 -0
- package/dist/parser/service/auth/schema.d.mts +1 -0
- package/dist/parser/service/http-adapter/index.d.mts +1 -0
- package/dist/parser/service/http-adapter/schema.d.mts +1 -0
- package/dist/parser/service/idp/types.d.mts +4 -0
- package/dist/parser/service/tailordb/types.d.mts +126 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +16 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
- package/dist/plugin/builtin/file-utils/index.d.mts +16 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -2
- package/dist/plugin/builtin/kysely-type/index.d.mts +16 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
- package/dist/plugin/builtin/seed/index.d.mts +45 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -2
- package/dist/plugin/get-generated-type.d.mts +17 -0
- package/dist/plugin/index.d.mts +3 -118
- package/dist/plugin/index.mjs +0 -1
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/manager.d.mts +1 -0
- package/dist/plugin/types.d.mts +245 -0
- package/dist/plugin/with-context.d.mts +102 -0
- package/dist/{registry-D0uB0OrK.mjs → registry-BozuxbPp.mjs} +1 -2
- package/dist/{registry-D0uB0OrK.mjs.map → registry-BozuxbPp.mjs.map} +1 -1
- package/dist/{repl-editor-DD5YP5mt.mjs → repl-editor-BmQOyZJd.mjs} +2 -3
- package/dist/{repl-editor-DD5YP5mt.mjs.map → repl-editor-BmQOyZJd.mjs.map} +1 -1
- package/dist/{rolldown-runtime-BkoGK1jX.mjs → rolldown-runtime-DXywRVcq.mjs} +0 -1
- package/dist/runtime/aigateway.d.mts +35 -0
- package/dist/runtime/aigateway.mjs +3 -0
- package/dist/runtime/authconnection.d.mts +31 -2
- package/dist/runtime/authconnection.mjs +1 -2
- package/dist/runtime/context.d.mts +67 -2
- package/dist/runtime/context.mjs +1 -2
- package/dist/runtime/file.d.mts +249 -2
- package/dist/runtime/file.mjs +1 -2
- package/dist/runtime/globals.d.mts +31 -20
- package/dist/runtime/globals.mjs +0 -1
- package/dist/runtime/iconv.d.mts +121 -2
- package/dist/runtime/iconv.mjs +1 -2
- package/dist/runtime/idp.d.mts +186 -2
- package/dist/runtime/idp.mjs +1 -2
- package/dist/runtime/index.d.mts +47 -9
- package/dist/runtime/index.mjs +9 -9
- package/dist/runtime/secretmanager.d.mts +54 -2
- package/dist/runtime/secretmanager.mjs +1 -2
- package/dist/{types-DTcZ2Yax.d.mts → runtime/types.d.mts} +1 -2
- package/dist/runtime/workflow.d.mts +107 -2
- package/dist/runtime/workflow.mjs +2 -3
- package/dist/{runtime-Cd375HD-.mjs → runtime-B8O6JFS2.mjs} +752 -256
- package/dist/runtime-B8O6JFS2.mjs.map +1 -0
- package/dist/{schema-C4fkpWV_.mjs → schema-DAdZSFOd.mjs} +3 -4
- package/dist/{schema-C4fkpWV_.mjs.map → schema-DAdZSFOd.mjs.map} +1 -1
- package/dist/{secret-file-eB3R3Fil.mjs → secret-file-VSVGy1V0.mjs} +2 -3
- package/dist/{secret-file-eB3R3Fil.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
- package/dist/{secretmanager-h3tBJV8f.mjs → secretmanager-BVxw3ih_.mjs} +2 -3
- package/dist/{secretmanager-h3tBJV8f.mjs.map → secretmanager-BVxw3ih_.mjs.map} +1 -1
- package/dist/seed/index.d.mts +1 -2
- package/dist/seed/index.mjs +0 -1
- package/dist/seed/index.mjs.map +1 -1
- package/dist/{seed-YAbtMy65.mjs → seed-DoMTMLcm.mjs} +3 -4
- package/dist/{seed-YAbtMy65.mjs.map → seed-DoMTMLcm.mjs.map} +1 -1
- package/dist/service-BXmdFwSH.mjs +3 -0
- package/dist/{service-DDWgZL_L2.mjs → service-DBFZQloR.mjs} +3 -4
- package/dist/service-DBFZQloR.mjs.map +1 -0
- package/dist/{service-B2Jd9CxS.mjs → service-DiEtAsvc.mjs} +3 -4
- package/dist/{service-B2Jd9CxS.mjs.map → service-DiEtAsvc.mjs.map} +1 -1
- package/dist/{service_pb-BsBR6yW5.mjs → service_pb-CIrhGwHk.mjs} +1 -2
- package/dist/{service_pb-BsBR6yW5.mjs.map → service_pb-CIrhGwHk.mjs.map} +1 -1
- package/dist/{service_pb-BJ9GsAnW.mjs → service_pb-DjwIn4jO.mjs} +1 -2
- package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +204 -0
- package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +58 -0
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +316 -0
- package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +161 -0
- package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +2070 -0
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +861 -0
- package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +112 -0
- package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +69 -0
- package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +439 -0
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +564 -0
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +145 -0
- package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +451 -0
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +192 -0
- package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +50 -0
- package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +407 -0
- package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +430 -0
- package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +73 -0
- package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +17 -0
- package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +309 -0
- package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +591 -0
- package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +330 -0
- package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +113 -0
- package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +346 -0
- package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +54 -0
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +3576 -0
- package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +187 -0
- package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +29 -0
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +429 -0
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +90 -0
- package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +684 -0
- package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +797 -0
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +330 -0
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +183 -0
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +842 -0
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +276 -0
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +2015 -0
- package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +483 -0
- package/dist/{telemetry-BQbbVo2t.mjs → telemetry-CdqJEzkj.mjs} +2 -3
- package/dist/{telemetry-BQbbVo2t.mjs.map → telemetry-CdqJEzkj.mjs.map} +1 -1
- package/dist/telemetry-ClwW5ohF.mjs +3 -0
- package/dist/types/aigateway.generated.d.mts +9 -0
- package/dist/types/app-config.generated.d.mts +4 -0
- package/dist/types/auth-connection.generated.d.mts +20 -0
- package/dist/types/auth.generated.d.mts +150 -0
- package/dist/types/executor.generated.d.mts +177 -0
- package/dist/types/generator-config.generated.d.mts +28 -0
- package/dist/types/helpers.d.mts +39 -0
- package/dist/types/http-adapter.generated.d.mts +17 -0
- package/dist/types/idp.generated.d.mts +584 -0
- package/dist/types/resolver.generated.d.mts +38 -0
- package/dist/types/secrets.generated.d.mts +14 -0
- package/dist/types/staticwebsite.generated.d.mts +10 -0
- package/dist/{types-rj8YJcEe.d.mts → types/tailordb.generated.d.mts} +2 -290
- package/dist/types/workflow.generated.d.mts +12 -0
- package/dist/types-qhFZ8y9B.mjs +4 -0
- package/dist/{types-D4QMmNWh.mjs → types-ywCGpzDZ.mjs} +2 -3
- package/dist/{types-D4QMmNWh.mjs.map → types-ywCGpzDZ.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +6 -89
- package/dist/utils/test/index.mjs +1 -2
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/utils/test/mock.d.mts +87 -0
- package/dist/vitest/environment.d.mts +1 -2
- package/dist/vitest/environment.mjs +1 -2
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.d.mts +4 -392
- package/dist/vitest/index.mjs +4 -5
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock-kysely.d.mts +62 -0
- package/dist/vitest/mock.d.mts +364 -0
- package/dist/vitest/setup.d.mts +1 -2
- package/dist/vitest/setup.mjs +2 -3
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/{workflow-C8I7shjM.mjs → workflow-DSwnYPPP.mjs} +10 -4
- package/dist/workflow-DSwnYPPP.mjs.map +1 -0
- package/docs/runtime.md +5 -1
- package/docs/services/aigateway.md +14 -0
- package/docs/services/tailordb-migration.md +2 -0
- package/docs/testing.md +48 -2
- package/package.json +6 -1
- package/dist/application-DmjIKQ-a.mjs.map +0 -1
- package/dist/application-a_ApFuPh.mjs +0 -4
- package/dist/authconnection-CqfaJfrC.d.mts +0 -32
- package/dist/context-CUBwSBq4.d.mts +0 -68
- package/dist/file-BzK8z3X-.d.mts +0 -250
- package/dist/globals-ByrCoDip.mjs.map +0 -1
- package/dist/iconv-kwrmd1U_.d.mts +0 -122
- package/dist/idp-BmYwCXnJ.d.mts +0 -187
- package/dist/index-BDBU7x-i.d.mts +0 -18
- package/dist/index-BSlv_YrG.d.mts +0 -46
- package/dist/index-BzGqTY5x.d.mts +0 -1315
- package/dist/index-D3_Au3wu.d.mts +0 -47
- package/dist/index-DtFRlrww.d.mts +0 -18
- package/dist/index-jeE3UvF2.d.mts +0 -18
- package/dist/job-BpsFXPbi.mjs.map +0 -1
- package/dist/mock-wf5qeZLi.mjs.map +0 -1
- package/dist/package-json-wzO6nV9O.mjs +0 -4
- package/dist/runtime-Cd375HD-.mjs.map +0 -1
- package/dist/secretmanager-CKLB3wAQ.d.mts +0 -55
- package/dist/service-CRaa4Joe.mjs +0 -4
- package/dist/service-DDWgZL_L2.mjs.map +0 -1
- package/dist/telemetry-w92bvGdC.mjs +0 -4
- package/dist/types-32lUMToj.mjs +0 -5
- package/dist/types-aqnqTCfO.d.mts +0 -602
- package/dist/workflow-C8I7shjM.mjs.map +0 -1
- package/dist/workflow-CMamswkK.d.mts +0 -96
- package/dist/workflow.generated-Da1zECDw.d.mts +0 -1348
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { r as withSpan } from "./telemetry-BQbbVo2t.mjs";
|
|
1
|
+
import { t as db } from "./schema-DAdZSFOd.mjs";
|
|
2
|
+
import { $ as CreateUserProfileConfigRequestSchema, A as UpdatePipelineServiceRequestSchema, At as Condition_Operator, B as UpdateExecutorExecutorRequestSchema, Ct as UserProfileProviderConfig_UserProfileProviderType, D as CreatePipelineResolverRequestSchema, Dt as ApplicationSchemaUpdateAttemptStatus, E as UpdateSecretManagerSecretRequestSchema, Et as UpdateApplicationRequestSchema, F as IdPPermissionOperator, G as CreateAuthHookRequestSchema, H as ExecutorTargetType, I as IdPPermissionPermit, J as CreateAuthOAuth2ClientRequestSchema, K as CreateAuthIDPConfigRequestSchema, L as FunctionExecution_Status, M as CreateIdPServiceRequestSchema, Mt as PageDirection, N as UpdateIdPServiceRequestSchema, O as CreatePipelineServiceRequestSchema, Ot as Subgraph_ServiceType, P as IdPLang, Q as CreateTenantConfigRequestSchema, S as UpdateStaticWebsiteRequestSchema, St as TenantProviderConfig_TenantProviderType, T as CreateSecretManagerVaultRequestSchema, Tt as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, U as ExecutorTriggerType, V as ExecutorJobStatus, W as CreateAuthConnectionRequestSchema, X as CreateAuthSCIMResourceRequestSchema, Y as CreateAuthSCIMConfigRequestSchema, Z as CreateAuthServiceRequestSchema, _ as TailorDBType_Permission_Operator, _t as AuthSCIMAttribute_Mutability, a as WorkspacePlatformUserRole, at as UpdateAuthSCIMConfigRequestSchema, b as AddCustomDomainRequestSchema, bt as AuthSCIMConfig_AuthorizationType, c as UpdateWorkflowRequestSchema, ct as UpdateTenantConfigRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as AuthConnection_Type, et as UpdateAuthConnectionRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as AuthHookPoint, g as TailorDBGQLPermission_Permit, gt as AuthOAuth2Client_GrantType, h as TailorDBGQLPermission_Operator, ht as AuthOAuth2Client_ClientType, it as UpdateAuthOAuth2ClientRequestSchema, j as PipelineResolver_OperationType, jt as FilterSchema, k as UpdatePipelineResolverRequestSchema, kt as ConditionSchema, l as WorkflowExecution_Status, lt as UpdateUserProfileConfigRequestSchema, m as TailorDBGQLPermission_Action, mt as AuthInvokerSchema, nt as UpdateAuthIDPConfigRequestSchema, o as CreateWorkflowJobFunctionRequestSchema, ot as UpdateAuthSCIMResourceRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as AuthIDPConfig_AuthType, q as CreateAuthMachineUserRequestSchema, rt as UpdateAuthMachineUserRequestSchema, s as CreateWorkflowRequestSchema, st as UpdateAuthServiceRequestSchema, t as OperatorService, tt as UpdateAuthHookRequestSchema, u as WorkflowJobExecution_Status, ut as AuthConnection_Status, v as TailorDBType_Permission_Permit, vt as AuthSCIMAttribute_Type, w as CreateSecretManagerSecretRequestSchema, wt as CreateApplicationRequestSchema, x as CreateStaticWebsiteRequestSchema, y as TailorDBType_PermitAction, yt as AuthSCIMAttribute_Uniqueness, z as CreateExecutorExecutorRequestSchema } from "./service_pb-CIrhGwHk.mjs";
|
|
3
|
+
import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
|
|
4
|
+
import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-BEiZZ3qT.mjs";
|
|
5
|
+
import { $ as initOperatorClient, A as loadAccessToken, G as fetchMachineUserToken, I as loadWorkspaceId, K as fetchPaged, L as platformConfigFromProfile, N as loadMachineUserName, P as loadPlatformClientConfig, R as readPlatformConfig, S as getDistDir, T as loadConfig, V as writePlatformConfig, W as fetchAll, X as getOAuth2ClientId, Y as getConsoleBaseUrl, Z as getPlatformBaseUrl, b as hasGenerationHooks, d as assertUniqueLocalTailorDBTypeNames, et as isDefaultPlatform, f as assertUniqueTailorDBTypeNamesWithExternal, h as platformBundleDefinePlugin, j as loadConfigPath, k as hasUserTokenEntry, l as buildExecutorArgsExpr, m as stringifyFunction, n as generatePluginFilesIfNeeded, nt as byName, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, tt as resolveStaticWebsiteUrls, u as buildResolverOperationHookExpr, w as hashFile, x as createBundleCache, y as getPluginGenerationDependencies } from "./application-Bb9NNp5m.mjs";
|
|
6
|
+
import { o as loadFilesWithIgnores, t as createExecutorService } from "./service-DiEtAsvc.mjs";
|
|
7
|
+
import { t as multiline } from "./multiline-sfHpTZZK.mjs";
|
|
8
|
+
import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
|
|
9
|
+
import { i as userAgent } from "./secret-file-VSVGy1V0.mjs";
|
|
10
|
+
import { n as isCLIError, t as createCLIError } from "./errors-Dtf2WPaW.mjs";
|
|
11
|
+
import { r as withSpan } from "./telemetry-CdqJEzkj.mjs";
|
|
13
12
|
import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
|
|
14
13
|
import { z } from "zod";
|
|
15
14
|
import { ScalarType, create, fromJson, toJson } from "@bufbuild/protobuf";
|
|
@@ -1118,9 +1117,10 @@ function extractAttributesFromConfig(config) {
|
|
|
1118
1117
|
* @param machineUserNames - Registered machine user names (used to narrow `authInvoker` strings)
|
|
1119
1118
|
* @param idpNames - Registered IdP names (used to narrow `idpUser*Trigger({ idp })` strings)
|
|
1120
1119
|
* @param connectionNames - Registered auth connection names (used to narrow `getConnectionToken()` strings)
|
|
1120
|
+
* @param aiGatewayNames - Registered AI Gateway names (used to narrow `aigateway.get()` strings)
|
|
1121
1121
|
* @returns Generated type definition source
|
|
1122
1122
|
*/
|
|
1123
|
-
function generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames) {
|
|
1123
|
+
function generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames, aiGatewayNames) {
|
|
1124
1124
|
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
|
|
1125
1125
|
const mapBody = !attributeMap || Object.keys(attributeMap).length === 0 ? "{}" : `{
|
|
1126
1126
|
${mapFields}
|
|
@@ -1144,6 +1144,10 @@ ${machineUserFields}
|
|
|
1144
1144
|
${idpNameFields}
|
|
1145
1145
|
}`;
|
|
1146
1146
|
const connectionNameFields = connectionNames?.length ? connectionNames.map((name) => ` ${isValidIdentifier(name) ? name : JSON.stringify(name)}: true;`).join("\n") : "";
|
|
1147
|
+
const connectionNameBody = !connectionNames || connectionNames.length === 0 ? "{}" : `{
|
|
1148
|
+
${connectionNameFields}
|
|
1149
|
+
}`;
|
|
1150
|
+
const aiGatewayNameFields = aiGatewayNames?.length ? aiGatewayNames.map((name) => ` ${isValidIdentifier(name) ? name : JSON.stringify(name)}: true;`).join("\n") : "";
|
|
1147
1151
|
return multiline`
|
|
1148
1152
|
// This file is auto-generated by @tailor-platform/sdk
|
|
1149
1153
|
// Do not edit this file manually
|
|
@@ -1155,8 +1159,9 @@ declare module "@tailor-platform/sdk" {
|
|
|
1155
1159
|
interface Env ${envBody}
|
|
1156
1160
|
interface MachineUserNameRegistry ${machineUserBody}
|
|
1157
1161
|
interface IdpNameRegistry ${idpNameBody}
|
|
1158
|
-
interface ConnectionNameRegistry ${
|
|
1159
|
-
${
|
|
1162
|
+
interface ConnectionNameRegistry ${connectionNameBody}
|
|
1163
|
+
interface AIGatewayNameRegistry ${!aiGatewayNames || aiGatewayNames.length === 0 ? "{}" : `{
|
|
1164
|
+
${aiGatewayNameFields}
|
|
1160
1165
|
}`}
|
|
1161
1166
|
}
|
|
1162
1167
|
|
|
@@ -1166,8 +1171,12 @@ export {};
|
|
|
1166
1171
|
}
|
|
1167
1172
|
function collectAttributesFromConfig(config) {
|
|
1168
1173
|
const idpNames = config.idp?.length ? [...new Set(config.idp.map((idp) => idp.name))] : void 0;
|
|
1174
|
+
const aiGatewayNames = config.aiGateways?.length ? [...new Set(config.aiGateways.map((gateway) => gateway.name))] : void 0;
|
|
1169
1175
|
const auth = config.auth;
|
|
1170
|
-
if (!auth || typeof auth !== "object") return idpNames
|
|
1176
|
+
if (!auth || typeof auth !== "object") return idpNames || aiGatewayNames ? {
|
|
1177
|
+
idpNames,
|
|
1178
|
+
aiGatewayNames
|
|
1179
|
+
} : {};
|
|
1171
1180
|
const machineUsersObj = auth.machineUsers;
|
|
1172
1181
|
const machineUserNames = machineUsersObj && typeof machineUsersObj === "object" ? Object.keys(machineUsersObj) : void 0;
|
|
1173
1182
|
const connectionsObj = auth.connections;
|
|
@@ -1195,7 +1204,8 @@ function collectAttributesFromConfig(config) {
|
|
|
1195
1204
|
attributeList,
|
|
1196
1205
|
machineUserNames,
|
|
1197
1206
|
idpNames,
|
|
1198
|
-
connectionNames
|
|
1207
|
+
connectionNames,
|
|
1208
|
+
aiGatewayNames
|
|
1199
1209
|
};
|
|
1200
1210
|
}
|
|
1201
1211
|
if ("machineUserAttributes" in auth) {
|
|
@@ -1203,7 +1213,8 @@ function collectAttributesFromConfig(config) {
|
|
|
1203
1213
|
if (!machineUserAttributes) return {
|
|
1204
1214
|
machineUserNames,
|
|
1205
1215
|
idpNames,
|
|
1206
|
-
connectionNames
|
|
1216
|
+
connectionNames,
|
|
1217
|
+
aiGatewayNames
|
|
1207
1218
|
};
|
|
1208
1219
|
return {
|
|
1209
1220
|
attributeMap: Object.entries(machineUserAttributes).reduce((acc, [key, field]) => {
|
|
@@ -1212,13 +1223,15 @@ function collectAttributesFromConfig(config) {
|
|
|
1212
1223
|
}, {}),
|
|
1213
1224
|
machineUserNames,
|
|
1214
1225
|
idpNames,
|
|
1215
|
-
connectionNames
|
|
1226
|
+
connectionNames,
|
|
1227
|
+
aiGatewayNames
|
|
1216
1228
|
};
|
|
1217
1229
|
}
|
|
1218
1230
|
return {
|
|
1219
1231
|
machineUserNames,
|
|
1220
1232
|
idpNames,
|
|
1221
|
-
connectionNames
|
|
1233
|
+
connectionNames,
|
|
1234
|
+
aiGatewayNames
|
|
1222
1235
|
};
|
|
1223
1236
|
}
|
|
1224
1237
|
/**
|
|
@@ -1243,16 +1256,17 @@ function resolveTypeDefinitionPath(configPath) {
|
|
|
1243
1256
|
async function generateUserTypes(options) {
|
|
1244
1257
|
const { config, configPath } = options;
|
|
1245
1258
|
try {
|
|
1246
|
-
const { attributeMap, attributeList, machineUserNames, idpNames, connectionNames } = extractAttributesFromConfig(config);
|
|
1259
|
+
const { attributeMap, attributeList, machineUserNames, idpNames, connectionNames, aiGatewayNames } = extractAttributesFromConfig(config);
|
|
1247
1260
|
if (!attributeMap && !attributeList) logger.info("No attributes found in configuration", { mode: "plain" });
|
|
1248
1261
|
if (attributeMap) logger.debug(`Extracted AttributeMap: ${JSON.stringify(attributeMap)}`);
|
|
1249
1262
|
if (attributeList) logger.debug(`Extracted AttributeList: ${JSON.stringify(attributeList)}`);
|
|
1250
1263
|
if (machineUserNames?.length) logger.debug(`Extracted MachineUserNames: ${JSON.stringify(machineUserNames)}`);
|
|
1251
1264
|
if (idpNames?.length) logger.debug(`Extracted IdpNames: ${JSON.stringify(idpNames)}`);
|
|
1252
1265
|
if (connectionNames?.length) logger.debug(`Extracted ConnectionNames: ${JSON.stringify(connectionNames)}`);
|
|
1266
|
+
if (aiGatewayNames?.length) logger.debug(`Extracted AIGatewayNames: ${JSON.stringify(aiGatewayNames)}`);
|
|
1253
1267
|
const env = config.env;
|
|
1254
1268
|
if (env) logger.debug(`Extracted Env: ${JSON.stringify(env)}`);
|
|
1255
|
-
const typeDefContent = generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames);
|
|
1269
|
+
const typeDefContent = generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames, aiGatewayNames);
|
|
1256
1270
|
const outputPath = resolveTypeDefinitionPath(configPath);
|
|
1257
1271
|
fs$1.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
1258
1272
|
fs$1.writeFileSync(outputPath, typeDefContent);
|
|
@@ -1806,14 +1820,13 @@ async function buildMetaRequest(params) {
|
|
|
1806
1820
|
* @template T
|
|
1807
1821
|
* @param params - Resource fetch parameters
|
|
1808
1822
|
* @param params.client - Operator client instance
|
|
1809
|
-
* @param params.workspaceId - Workspace ID
|
|
1810
1823
|
* @param params.fetchPage - Function that fetches one resource page
|
|
1811
1824
|
* @param params.getName - Function that extracts the resource name
|
|
1812
1825
|
* @param params.getTrn - Function that builds the resource TRN
|
|
1813
1826
|
* @returns Existing resources keyed by resource name, with SDK labels attached
|
|
1814
1827
|
*/
|
|
1815
1828
|
async function fetchExistingResourcesWithLabels(params) {
|
|
1816
|
-
const { client,
|
|
1829
|
+
const { client, fetchPage, getName, getTrn } = params;
|
|
1817
1830
|
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
1818
1831
|
try {
|
|
1819
1832
|
return await fetchPage(pageToken, maxPageSize);
|
|
@@ -1826,7 +1839,7 @@ async function fetchExistingResourcesWithLabels(params) {
|
|
|
1826
1839
|
await Promise.all(withoutLabel.map(async (resource) => {
|
|
1827
1840
|
const name = getName(resource);
|
|
1828
1841
|
if (!name) return;
|
|
1829
|
-
const { metadata } = await client.getMetadata({ trn: getTrn(
|
|
1842
|
+
const { metadata } = await client.getMetadata({ trn: getTrn(name) });
|
|
1830
1843
|
existingResources[name] = {
|
|
1831
1844
|
resource,
|
|
1832
1845
|
label: metadata?.labels[sdkNameLabelKey],
|
|
@@ -1931,7 +1944,6 @@ async function planAIGateway(context) {
|
|
|
1931
1944
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
1932
1945
|
const existingGateways = await fetchExistingResourcesWithLabels({
|
|
1933
1946
|
client,
|
|
1934
|
-
workspaceId,
|
|
1935
1947
|
fetchPage: async (pageToken, pageSize) => {
|
|
1936
1948
|
const { aigateways, nextPageToken } = await client.listAIGateways({
|
|
1937
1949
|
workspaceId,
|
|
@@ -1941,7 +1953,7 @@ async function planAIGateway(context) {
|
|
|
1941
1953
|
return [aigateways, nextPageToken];
|
|
1942
1954
|
},
|
|
1943
1955
|
getName: (resource) => resource.name,
|
|
1944
|
-
getTrn: (
|
|
1956
|
+
getTrn: (name) => resourceTrn(workspaceId, "aigateway", name)
|
|
1945
1957
|
});
|
|
1946
1958
|
const aiGatewayServices = forRemoval ? [] : application.aiGatewayServices;
|
|
1947
1959
|
const expectedLocalWebsites = new Set(application.staticWebsiteServices.map((website) => website.name));
|
|
@@ -2726,8 +2738,9 @@ async function planFunctionRegistry(client, workspaceId, appName, appId, entries
|
|
|
2726
2738
|
const conflicts = [];
|
|
2727
2739
|
const unmanaged = [];
|
|
2728
2740
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2741
|
+
const existingMap = await fetchExistingResourcesWithLabels({
|
|
2742
|
+
client,
|
|
2743
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
2731
2744
|
const response = await client.listFunctionRegistries({
|
|
2732
2745
|
workspaceId,
|
|
2733
2746
|
pageToken,
|
|
@@ -2737,20 +2750,10 @@ async function planFunctionRegistry(client, workspaceId, appName, appId, entries
|
|
|
2737
2750
|
name: f.name,
|
|
2738
2751
|
contentHash: f.contentHash
|
|
2739
2752
|
})), response.nextPageToken];
|
|
2740
|
-
}
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
}
|
|
2753
|
+
},
|
|
2754
|
+
getName: (func) => func.name,
|
|
2755
|
+
getTrn: (name) => resourceTrn(workspaceId, "function_registry", name)
|
|
2744
2756
|
});
|
|
2745
|
-
const existingMap = {};
|
|
2746
|
-
await Promise.all(existingFunctions.map(async (func) => {
|
|
2747
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "function_registry", func.name) });
|
|
2748
|
-
existingMap[func.name] = {
|
|
2749
|
-
resource: func,
|
|
2750
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
2751
|
-
allLabels: metadata?.labels
|
|
2752
|
-
};
|
|
2753
|
-
}));
|
|
2754
2757
|
for (const entry of entries) {
|
|
2755
2758
|
const existing = existingMap[entry.name];
|
|
2756
2759
|
const metaRequest = await buildMetaRequest({
|
|
@@ -3408,29 +3411,19 @@ async function planServices$3(client, workspaceId, appName, appId, idps, idpUser
|
|
|
3408
3411
|
const conflicts = [];
|
|
3409
3412
|
const unmanaged = [];
|
|
3410
3413
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
3411
|
-
const
|
|
3412
|
-
|
|
3414
|
+
const existingServices = await fetchExistingResourcesWithLabels({
|
|
3415
|
+
client,
|
|
3416
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
3413
3417
|
const { idpServices, nextPageToken } = await client.listIdPServices({
|
|
3414
3418
|
workspaceId,
|
|
3415
3419
|
pageToken,
|
|
3416
3420
|
pageSize: maxPageSize
|
|
3417
3421
|
});
|
|
3418
3422
|
return [idpServices, nextPageToken];
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
}
|
|
3423
|
+
},
|
|
3424
|
+
getName: (resource) => resource.namespace?.name,
|
|
3425
|
+
getTrn: (name) => resourceTrn(workspaceId, "idp", name)
|
|
3423
3426
|
});
|
|
3424
|
-
const existingServices = {};
|
|
3425
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
3426
|
-
if (!resource.namespace?.name) return;
|
|
3427
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "idp", resource.namespace.name) });
|
|
3428
|
-
existingServices[resource.namespace.name] = {
|
|
3429
|
-
resource,
|
|
3430
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
3431
|
-
allLabels: metadata?.labels
|
|
3432
|
-
};
|
|
3433
|
-
}));
|
|
3434
3427
|
for (const idp of idps) {
|
|
3435
3428
|
const namespaceName = idp.name;
|
|
3436
3429
|
const existing = existingServices[namespaceName];
|
|
@@ -3806,29 +3799,19 @@ async function planServices$2(client, workspaceId, appName, appId, auths, forceA
|
|
|
3806
3799
|
const conflicts = [];
|
|
3807
3800
|
const unmanaged = [];
|
|
3808
3801
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
3809
|
-
const
|
|
3810
|
-
|
|
3802
|
+
const existingServices = await fetchExistingResourcesWithLabels({
|
|
3803
|
+
client,
|
|
3804
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
3811
3805
|
const { authServices, nextPageToken } = await client.listAuthServices({
|
|
3812
3806
|
workspaceId,
|
|
3813
3807
|
pageToken,
|
|
3814
3808
|
pageSize: maxPageSize
|
|
3815
3809
|
});
|
|
3816
3810
|
return [authServices, nextPageToken];
|
|
3817
|
-
}
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
}
|
|
3811
|
+
},
|
|
3812
|
+
getName: (resource) => resource.namespace?.name,
|
|
3813
|
+
getTrn: (name) => resourceTrn(workspaceId, "auth", name)
|
|
3821
3814
|
});
|
|
3822
|
-
const existingServices = {};
|
|
3823
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
3824
|
-
if (!resource.namespace?.name) return;
|
|
3825
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "auth", resource.namespace.name) });
|
|
3826
|
-
existingServices[resource.namespace.name] = {
|
|
3827
|
-
resource,
|
|
3828
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
3829
|
-
allLabels: metadata?.labels
|
|
3830
|
-
};
|
|
3831
|
-
}));
|
|
3832
3815
|
for (const auth of auths) {
|
|
3833
3816
|
const { config } = auth;
|
|
3834
3817
|
const existing = existingServices[config.name];
|
|
@@ -5159,7 +5142,6 @@ async function planExecutor(context) {
|
|
|
5159
5142
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5160
5143
|
const existingExecutors = await fetchExistingResourcesWithLabels({
|
|
5161
5144
|
client,
|
|
5162
|
-
workspaceId,
|
|
5163
5145
|
fetchPage: async (pageToken, pageSize) => {
|
|
5164
5146
|
const { executors, nextPageToken } = await client.listExecutorExecutors({
|
|
5165
5147
|
workspaceId,
|
|
@@ -5169,7 +5151,7 @@ async function planExecutor(context) {
|
|
|
5169
5151
|
return [executors, nextPageToken];
|
|
5170
5152
|
},
|
|
5171
5153
|
getName: (resource) => resource.name,
|
|
5172
|
-
getTrn: (
|
|
5154
|
+
getTrn: (name) => resourceTrn(workspaceId, "executor", name)
|
|
5173
5155
|
});
|
|
5174
5156
|
const executors = forRemoval ? {} : await application.executorService?.loadExecutors() ?? {};
|
|
5175
5157
|
for (const executor of Object.values(executors)) {
|
|
@@ -5594,29 +5576,19 @@ async function planServices$1(client, workspaceId, appName, appId, pipelines) {
|
|
|
5594
5576
|
const conflicts = [];
|
|
5595
5577
|
const unmanaged = [];
|
|
5596
5578
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5597
|
-
const
|
|
5598
|
-
|
|
5579
|
+
const existingServices = await fetchExistingResourcesWithLabels({
|
|
5580
|
+
client,
|
|
5581
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
5599
5582
|
const { pipelineServices, nextPageToken } = await client.listPipelineServices({
|
|
5600
5583
|
workspaceId,
|
|
5601
5584
|
pageToken,
|
|
5602
5585
|
pageSize: maxPageSize
|
|
5603
5586
|
});
|
|
5604
5587
|
return [pipelineServices, nextPageToken];
|
|
5605
|
-
}
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
}
|
|
5588
|
+
},
|
|
5589
|
+
getName: (resource) => resource.namespace?.name,
|
|
5590
|
+
getTrn: (name) => resourceTrn(workspaceId, "pipeline", name)
|
|
5609
5591
|
});
|
|
5610
|
-
const existingServices = {};
|
|
5611
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
5612
|
-
if (!resource.namespace?.name) return;
|
|
5613
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "pipeline", resource.namespace.name) });
|
|
5614
|
-
existingServices[resource.namespace.name] = {
|
|
5615
|
-
resource,
|
|
5616
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
5617
|
-
allLabels: metadata?.labels
|
|
5618
|
-
};
|
|
5619
|
-
}));
|
|
5620
5592
|
for (const pipeline of pipelines) {
|
|
5621
5593
|
const existing = existingServices[pipeline.namespace];
|
|
5622
5594
|
const metaRequest = await buildMetaRequest({
|
|
@@ -5929,28 +5901,19 @@ async function planSecretManager(context) {
|
|
|
5929
5901
|
const conflicts = [];
|
|
5930
5902
|
const unmanaged = [];
|
|
5931
5903
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5932
|
-
const
|
|
5933
|
-
|
|
5904
|
+
const existingVaults = await fetchExistingResourcesWithLabels({
|
|
5905
|
+
client,
|
|
5906
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
5934
5907
|
const { vaults, nextPageToken } = await client.listSecretManagerVaults({
|
|
5935
5908
|
workspaceId,
|
|
5936
5909
|
pageToken,
|
|
5937
5910
|
pageSize: maxPageSize
|
|
5938
5911
|
});
|
|
5939
5912
|
return [vaults, nextPageToken];
|
|
5940
|
-
}
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
}
|
|
5913
|
+
},
|
|
5914
|
+
getName: (resource) => resource.name,
|
|
5915
|
+
getTrn: (name) => resourceTrn(workspaceId, "vault", name)
|
|
5944
5916
|
});
|
|
5945
|
-
const existingVaults = {};
|
|
5946
|
-
await Promise.all(existingVaultList.map(async (resource) => {
|
|
5947
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "vault", resource.name) });
|
|
5948
|
-
existingVaults[resource.name] = {
|
|
5949
|
-
resource,
|
|
5950
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
5951
|
-
allLabels: metadata?.labels
|
|
5952
|
-
};
|
|
5953
|
-
}));
|
|
5954
5917
|
const state = loadSecretsState();
|
|
5955
5918
|
const skippedSecrets = [];
|
|
5956
5919
|
await Promise.all(secretVaults.map(async (vault) => {
|
|
@@ -6190,7 +6153,6 @@ async function planStaticWebsite(context) {
|
|
|
6190
6153
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
6191
6154
|
const existingWebsites = await fetchExistingResourcesWithLabels({
|
|
6192
6155
|
client,
|
|
6193
|
-
workspaceId,
|
|
6194
6156
|
fetchPage: async (pageToken, pageSize) => {
|
|
6195
6157
|
const { staticwebsites, nextPageToken } = await client.listStaticWebsites({
|
|
6196
6158
|
workspaceId,
|
|
@@ -6200,7 +6162,7 @@ async function planStaticWebsite(context) {
|
|
|
6200
6162
|
return [staticwebsites, nextPageToken];
|
|
6201
6163
|
},
|
|
6202
6164
|
getName: (resource) => resource.name,
|
|
6203
|
-
getTrn: (
|
|
6165
|
+
getTrn: (name) => resourceTrn(workspaceId, "staticwebsite", name)
|
|
6204
6166
|
});
|
|
6205
6167
|
const ownedWebsiteNames = /* @__PURE__ */ new Set();
|
|
6206
6168
|
const staticWebsiteServices = forRemoval ? [] : application.staticWebsiteServices;
|
|
@@ -6403,6 +6365,7 @@ function formatDiffChange(change) {
|
|
|
6403
6365
|
case "type_added": return ` + [Type] ${change.typeName} (new type)`;
|
|
6404
6366
|
case "type_removed": return ` - [Type] ${change.typeName} (removed)`;
|
|
6405
6367
|
case "type_modified": return ` ~ [Type] ${change.typeName}: ${change.reason}`;
|
|
6368
|
+
case "type_settings_modified": return ` ~ [Type Settings] ${change.typeName}: ${change.reason ?? "settings changed"}`;
|
|
6406
6369
|
case "field_added": {
|
|
6407
6370
|
const typeStr = formatFieldType(change.after);
|
|
6408
6371
|
return ` + ${change.fieldName}: ${typeStr}`;
|
|
@@ -6500,6 +6463,7 @@ const DIFF_CHANGE_LABELS = {
|
|
|
6500
6463
|
type_added: "type(s) added",
|
|
6501
6464
|
type_removed: "type(s) removed",
|
|
6502
6465
|
type_modified: "type(s) modified",
|
|
6466
|
+
type_settings_modified: "type setting(s) modified",
|
|
6503
6467
|
field_added: "field(s) added",
|
|
6504
6468
|
field_removed: "field(s) removed",
|
|
6505
6469
|
field_modified: "field(s) modified",
|
|
@@ -6719,6 +6683,21 @@ const typeSettingsPatchSchema = z.looseObject({
|
|
|
6719
6683
|
indexes: snapshotRecordSchema(snapshotIndexConfigSchema).optional(),
|
|
6720
6684
|
files: snapshotRecordSchema(z.string()).optional()
|
|
6721
6685
|
});
|
|
6686
|
+
const snapshotTypeSettingsStateSchema = z.looseObject({
|
|
6687
|
+
description: z.string().optional(),
|
|
6688
|
+
pluralForm: z.string(),
|
|
6689
|
+
settings: z.looseObject({
|
|
6690
|
+
aggregation: z.boolean().optional(),
|
|
6691
|
+
bulkUpsert: z.boolean().optional(),
|
|
6692
|
+
gqlOperations: z.looseObject({
|
|
6693
|
+
create: z.boolean().optional(),
|
|
6694
|
+
update: z.boolean().optional(),
|
|
6695
|
+
delete: z.boolean().optional(),
|
|
6696
|
+
read: z.boolean().optional()
|
|
6697
|
+
}).optional(),
|
|
6698
|
+
publishEvents: z.boolean().optional()
|
|
6699
|
+
}).optional()
|
|
6700
|
+
});
|
|
6722
6701
|
const snapshotPermissionStateSchema = z.looseObject({
|
|
6723
6702
|
recordPermission: snapshotRecordPermissionSchema.optional(),
|
|
6724
6703
|
gqlPermission: snapshotGqlPermissionSchema.optional()
|
|
@@ -6742,6 +6721,13 @@ const typeModifiedChangeSchema = z.looseObject({
|
|
|
6742
6721
|
before: typeSettingsPatchSchema.optional(),
|
|
6743
6722
|
after: typeSettingsPatchSchema.optional()
|
|
6744
6723
|
});
|
|
6724
|
+
const typeSettingsModifiedChangeSchema = z.looseObject({
|
|
6725
|
+
kind: z.literal("type_settings_modified"),
|
|
6726
|
+
typeName: z.string(),
|
|
6727
|
+
reason: z.string().optional(),
|
|
6728
|
+
before: snapshotTypeSettingsStateSchema,
|
|
6729
|
+
after: snapshotTypeSettingsStateSchema
|
|
6730
|
+
});
|
|
6745
6731
|
const fieldAddedChangeSchema = z.looseObject({
|
|
6746
6732
|
kind: z.literal("field_added"),
|
|
6747
6733
|
typeName: z.string(),
|
|
@@ -6844,6 +6830,7 @@ const diffChangeSchema = z.discriminatedUnion("kind", [
|
|
|
6844
6830
|
typeAddedChangeSchema,
|
|
6845
6831
|
typeRemovedChangeSchema,
|
|
6846
6832
|
typeModifiedChangeSchema,
|
|
6833
|
+
typeSettingsModifiedChangeSchema,
|
|
6847
6834
|
fieldAddedChangeSchema,
|
|
6848
6835
|
fieldRemovedChangeSchema,
|
|
6849
6836
|
fieldModifiedChangeSchema,
|
|
@@ -7307,6 +7294,16 @@ function applyDiffToSnapshot(snapshot, diff) {
|
|
|
7307
7294
|
}
|
|
7308
7295
|
break;
|
|
7309
7296
|
}
|
|
7297
|
+
case "type_settings_modified": {
|
|
7298
|
+
const existing = types[change.typeName];
|
|
7299
|
+
if (existing) types[change.typeName] = {
|
|
7300
|
+
...existing,
|
|
7301
|
+
description: change.after.description,
|
|
7302
|
+
pluralForm: change.after.pluralForm,
|
|
7303
|
+
settings: change.after.settings ?? {}
|
|
7304
|
+
};
|
|
7305
|
+
break;
|
|
7306
|
+
}
|
|
7310
7307
|
case "field_added":
|
|
7311
7308
|
case "field_modified": {
|
|
7312
7309
|
const existing = types[change.typeName];
|
|
@@ -7683,10 +7680,10 @@ function compareIndexes(ctx, typeName, oldIndexes, newIndexes) {
|
|
|
7683
7680
|
const oldIndex = assertDefined(assertDefined(oldIndexes, "oldIndexes is undefined when oldKeys has entry")[indexName], `index "${indexName}" missing from oldIndexes`);
|
|
7684
7681
|
const oldFieldsStr = JSON.stringify(oldIndex.fields.toSorted());
|
|
7685
7682
|
const newFieldsStr = JSON.stringify(newIndex.fields.toSorted());
|
|
7686
|
-
if (oldFieldsStr !== newFieldsStr || oldIndex.unique !== newIndex.unique) {
|
|
7683
|
+
if (oldFieldsStr !== newFieldsStr || (oldIndex.unique ?? false) !== (newIndex.unique ?? false)) {
|
|
7687
7684
|
const reasons = [];
|
|
7688
7685
|
if (oldFieldsStr !== newFieldsStr) reasons.push("fields changed");
|
|
7689
|
-
if (oldIndex.unique !== newIndex.unique) reasons.push("unique constraint changed");
|
|
7686
|
+
if ((oldIndex.unique ?? false) !== (newIndex.unique ?? false)) reasons.push("unique constraint changed");
|
|
7690
7687
|
ctx.changes.push({
|
|
7691
7688
|
kind: "index_modified",
|
|
7692
7689
|
typeName,
|
|
@@ -7766,6 +7763,7 @@ function compareRelationships(ctx, typeName, relationshipType, oldRelationships,
|
|
|
7766
7763
|
if (oldRel.targetField !== newRel.targetField) reasons.push("targetField changed");
|
|
7767
7764
|
if (oldRel.sourceField !== newRel.sourceField) reasons.push("sourceField changed");
|
|
7768
7765
|
if (oldRel.isArray !== newRel.isArray) reasons.push("isArray changed");
|
|
7766
|
+
if (oldRel.description !== newRel.description) reasons.push("description changed");
|
|
7769
7767
|
if (reasons.length > 0) ctx.changes.push({
|
|
7770
7768
|
kind: "relationship_modified",
|
|
7771
7769
|
typeName,
|
|
@@ -7788,8 +7786,12 @@ function compareRelationships(ctx, typeName, relationshipType, oldRelationships,
|
|
|
7788
7786
|
* @returns {void}
|
|
7789
7787
|
*/
|
|
7790
7788
|
function comparePermissions(ctx, typeName, oldRecordPerm, newRecordPerm, oldGqlPerm, newGqlPerm) {
|
|
7791
|
-
const
|
|
7792
|
-
const
|
|
7789
|
+
const oldComparableRecordPerm = comparableRecordPermission(oldRecordPerm);
|
|
7790
|
+
const newComparableRecordPerm = comparableRecordPermission(newRecordPerm);
|
|
7791
|
+
const recordPermChanged = JSON.stringify(oldComparableRecordPerm ?? null) !== JSON.stringify(newComparableRecordPerm ?? null);
|
|
7792
|
+
const oldComparableGqlPerm = comparableGqlPermission(oldGqlPerm);
|
|
7793
|
+
const newComparableGqlPerm = comparableGqlPermission(newGqlPerm);
|
|
7794
|
+
const gqlPermChanged = JSON.stringify(oldComparableGqlPerm ?? null) !== JSON.stringify(newComparableGqlPerm ?? null);
|
|
7793
7795
|
if (recordPermChanged || gqlPermChanged) {
|
|
7794
7796
|
const reasons = [];
|
|
7795
7797
|
if (recordPermChanged) reasons.push("record permission");
|
|
@@ -7799,16 +7801,95 @@ function comparePermissions(ctx, typeName, oldRecordPerm, newRecordPerm, oldGqlP
|
|
|
7799
7801
|
typeName,
|
|
7800
7802
|
reason: `${reasons.join(" and ")} changed`,
|
|
7801
7803
|
before: {
|
|
7802
|
-
recordPermission:
|
|
7803
|
-
gqlPermission:
|
|
7804
|
+
recordPermission: oldComparableRecordPerm,
|
|
7805
|
+
gqlPermission: oldComparableGqlPerm
|
|
7804
7806
|
},
|
|
7805
7807
|
after: {
|
|
7806
|
-
recordPermission:
|
|
7807
|
-
gqlPermission:
|
|
7808
|
+
recordPermission: newComparableRecordPerm,
|
|
7809
|
+
gqlPermission: newComparableGqlPerm
|
|
7808
7810
|
}
|
|
7809
7811
|
});
|
|
7810
7812
|
}
|
|
7811
7813
|
}
|
|
7814
|
+
const GQL_ACTION_ORDER = {
|
|
7815
|
+
all: 0,
|
|
7816
|
+
create: 1,
|
|
7817
|
+
read: 2,
|
|
7818
|
+
update: 3,
|
|
7819
|
+
delete: 4,
|
|
7820
|
+
aggregate: 5,
|
|
7821
|
+
bulkUpsert: 6
|
|
7822
|
+
};
|
|
7823
|
+
function sortByJson(items) {
|
|
7824
|
+
return items.map((item) => [JSON.stringify(item), item]).toSorted(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([, item]) => item);
|
|
7825
|
+
}
|
|
7826
|
+
function comparableGqlPermission(permission) {
|
|
7827
|
+
const policies = permission?.map((policy) => ({
|
|
7828
|
+
...policy,
|
|
7829
|
+
conditions: sortByJson(policy.conditions),
|
|
7830
|
+
actions: policy.actions.toSorted((left, right) => GQL_ACTION_ORDER[left] - GQL_ACTION_ORDER[right])
|
|
7831
|
+
}));
|
|
7832
|
+
return policies && policies.length > 0 ? sortByJson(policies) : void 0;
|
|
7833
|
+
}
|
|
7834
|
+
function comparableRecordPermission(permission) {
|
|
7835
|
+
if (!permission) return void 0;
|
|
7836
|
+
if (!Object.values(permission).some((policies) => policies.length > 0)) return void 0;
|
|
7837
|
+
return {
|
|
7838
|
+
create: sortByJson(permission.create.map(canonicalActionPermission)),
|
|
7839
|
+
read: sortByJson(permission.read.map(canonicalActionPermission)),
|
|
7840
|
+
update: sortByJson(permission.update.map(canonicalActionPermission)),
|
|
7841
|
+
delete: sortByJson(permission.delete.map(canonicalActionPermission))
|
|
7842
|
+
};
|
|
7843
|
+
}
|
|
7844
|
+
function canonicalActionPermission(policy) {
|
|
7845
|
+
return {
|
|
7846
|
+
...policy,
|
|
7847
|
+
conditions: sortByJson(policy.conditions)
|
|
7848
|
+
};
|
|
7849
|
+
}
|
|
7850
|
+
function normalizeComparableGqlOperations(operations) {
|
|
7851
|
+
if (!operations) return void 0;
|
|
7852
|
+
return {
|
|
7853
|
+
create: operations.create ?? true,
|
|
7854
|
+
update: operations.update ?? true,
|
|
7855
|
+
delete: operations.delete ?? true,
|
|
7856
|
+
read: operations.read ?? true
|
|
7857
|
+
};
|
|
7858
|
+
}
|
|
7859
|
+
function normalizeComparableSettings(settings) {
|
|
7860
|
+
const normalized = {};
|
|
7861
|
+
if (settings?.aggregation === true) normalized.aggregation = true;
|
|
7862
|
+
if (settings?.bulkUpsert === true) normalized.bulkUpsert = true;
|
|
7863
|
+
if (settings?.publishEvents === true) normalized.publishEvents = true;
|
|
7864
|
+
const gqlOperations = normalizeComparableGqlOperations(settings?.gqlOperations);
|
|
7865
|
+
if (gqlOperations) normalized.gqlOperations = gqlOperations;
|
|
7866
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
7867
|
+
}
|
|
7868
|
+
function typeSettingsState(description, pluralForm, settings) {
|
|
7869
|
+
return {
|
|
7870
|
+
...description ? { description } : {},
|
|
7871
|
+
pluralForm,
|
|
7872
|
+
...settings && { settings }
|
|
7873
|
+
};
|
|
7874
|
+
}
|
|
7875
|
+
function comparableTypeSettings(type) {
|
|
7876
|
+
return typeSettingsState(type.description, inflection.camelize(type.pluralForm, true), normalizeComparableSettings(type.settings));
|
|
7877
|
+
}
|
|
7878
|
+
function snapshotTypeSettingsState(type) {
|
|
7879
|
+
return typeSettingsState(type.description, type.pluralForm, type.settings ?? {});
|
|
7880
|
+
}
|
|
7881
|
+
function compareTypeSettings(ctx, typeName, previous, current) {
|
|
7882
|
+
const previousComparable = comparableTypeSettings(previous);
|
|
7883
|
+
const currentComparable = comparableTypeSettings(current);
|
|
7884
|
+
if (JSON.stringify(previousComparable) === JSON.stringify(currentComparable)) return;
|
|
7885
|
+
ctx.changes.push({
|
|
7886
|
+
kind: "type_settings_modified",
|
|
7887
|
+
typeName,
|
|
7888
|
+
reason: "settings changed",
|
|
7889
|
+
before: snapshotTypeSettingsState(previous),
|
|
7890
|
+
after: snapshotTypeSettingsState(current)
|
|
7891
|
+
});
|
|
7892
|
+
}
|
|
7812
7893
|
/**
|
|
7813
7894
|
* Compare two snapshots and generate a diff
|
|
7814
7895
|
* @param {SchemaSnapshot} previous - Previous schema snapshot
|
|
@@ -7846,6 +7927,7 @@ function compareNormalizedSnapshots(previous, current) {
|
|
|
7846
7927
|
if (!previousTypeNames.has(typeName)) continue;
|
|
7847
7928
|
const prevType = assertDefined(previous.types[typeName], `type "${typeName}" missing from previous snapshot`);
|
|
7848
7929
|
const currType = assertDefined(current.types[typeName], `type "${typeName}" missing from current snapshot`);
|
|
7930
|
+
compareTypeSettings(ctx, typeName, prevType, currType);
|
|
7849
7931
|
compareTypeFields(ctx, typeName, prevType, currType);
|
|
7850
7932
|
compareIndexes(ctx, typeName, prevType.indexes, currType.indexes);
|
|
7851
7933
|
compareFiles(ctx, typeName, prevType.files, currType.files);
|
|
@@ -7947,6 +8029,49 @@ function assertValidMigrationFiles(migrationsDir, namespace) {
|
|
|
7947
8029
|
throw new Error(`Migration file validation failed for namespace "${namespace}":\n${errorMessages}`);
|
|
7948
8030
|
}
|
|
7949
8031
|
}
|
|
8032
|
+
function convertRemoteFieldToSnapshot(remoteField) {
|
|
8033
|
+
const config = {
|
|
8034
|
+
type: remoteField.type,
|
|
8035
|
+
required: remoteField.required
|
|
8036
|
+
};
|
|
8037
|
+
if (remoteField.array) config.array = true;
|
|
8038
|
+
if (remoteField.index) config.index = true;
|
|
8039
|
+
if (remoteField.unique) config.unique = true;
|
|
8040
|
+
if (remoteField.foreignKey) {
|
|
8041
|
+
config.foreignKey = true;
|
|
8042
|
+
if (remoteField.foreignKeyType) config.foreignKeyType = remoteField.foreignKeyType;
|
|
8043
|
+
if (remoteField.foreignKeyField) config.foreignKeyField = remoteField.foreignKeyField;
|
|
8044
|
+
}
|
|
8045
|
+
const allowedValues = remoteField.allowedValues;
|
|
8046
|
+
if (allowedValues.length > 0) config.allowedValues = allowedValues.map((v) => ({
|
|
8047
|
+
value: v.value,
|
|
8048
|
+
...v.description && { description: v.description }
|
|
8049
|
+
}));
|
|
8050
|
+
if (remoteField.description) config.description = remoteField.description;
|
|
8051
|
+
if (remoteField.vector) config.vector = true;
|
|
8052
|
+
if (remoteField.hooks) {
|
|
8053
|
+
config.hooks = {};
|
|
8054
|
+
if (remoteField.hooks.create?.expr) config.hooks.create = { expr: remoteField.hooks.create.expr };
|
|
8055
|
+
if (remoteField.hooks.update?.expr) config.hooks.update = { expr: remoteField.hooks.update.expr };
|
|
8056
|
+
}
|
|
8057
|
+
const validate = remoteField.validate;
|
|
8058
|
+
if (validate.length > 0) config.validate = validate.map((v) => ({
|
|
8059
|
+
script: { expr: convertRemoteValidateExpression(v.script?.expr ?? "", v.action) },
|
|
8060
|
+
errorMessage: v.errorMessage ?? ""
|
|
8061
|
+
}));
|
|
8062
|
+
if (remoteField.serial) config.serial = {
|
|
8063
|
+
start: Number(remoteField.serial.start),
|
|
8064
|
+
...remoteField.serial.maxValue && { maxValue: Number(remoteField.serial.maxValue) },
|
|
8065
|
+
...remoteField.serial.format && { format: remoteField.serial.format }
|
|
8066
|
+
};
|
|
8067
|
+
if (remoteField.scale !== void 0) config.scale = remoteField.scale;
|
|
8068
|
+
const nestedFields = remoteField.fields;
|
|
8069
|
+
if (Object.keys(nestedFields).length > 0) {
|
|
8070
|
+
config.fields = createSnapshotRecord();
|
|
8071
|
+
for (const [fieldName, nestedField] of Object.entries(nestedFields)) config.fields[fieldName] = convertRemoteFieldToSnapshot(nestedField);
|
|
8072
|
+
}
|
|
8073
|
+
return config;
|
|
8074
|
+
}
|
|
7950
8075
|
/**
|
|
7951
8076
|
* Convert remote ParsedTailorDBType to SnapshotFieldConfig for comparison
|
|
7952
8077
|
* @param {ProtoTailorDBType} remoteType - Remote TailorDB type from API
|
|
@@ -7955,62 +8080,204 @@ function assertValidMigrationFiles(migrationsDir, namespace) {
|
|
|
7955
8080
|
function convertRemoteFieldsToSnapshot(remoteType) {
|
|
7956
8081
|
const fields = createSnapshotRecord();
|
|
7957
8082
|
const remoteFields = remoteType.schema?.fields ?? {};
|
|
7958
|
-
for (const [fieldName, remoteField] of Object.entries(remoteFields))
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
if (remoteField.hooks) {
|
|
7978
|
-
config.hooks = {};
|
|
7979
|
-
if (remoteField.hooks.create?.expr) config.hooks.create = { expr: remoteField.hooks.create.expr };
|
|
7980
|
-
if (remoteField.hooks.update?.expr) config.hooks.update = { expr: remoteField.hooks.update.expr };
|
|
7981
|
-
}
|
|
7982
|
-
if (remoteField.validate.length > 0) config.validate = remoteField.validate.map((v) => ({
|
|
7983
|
-
script: { expr: v.script?.expr ?? "" },
|
|
7984
|
-
errorMessage: v.errorMessage ?? ""
|
|
7985
|
-
}));
|
|
7986
|
-
if (remoteField.serial) config.serial = {
|
|
7987
|
-
start: Number(remoteField.serial.start),
|
|
7988
|
-
...remoteField.serial.maxValue && { maxValue: Number(remoteField.serial.maxValue) },
|
|
7989
|
-
...remoteField.serial.format && { format: remoteField.serial.format }
|
|
8083
|
+
for (const [fieldName, remoteField] of Object.entries(remoteFields)) fields[fieldName] = convertRemoteFieldToSnapshot(remoteField);
|
|
8084
|
+
return fields;
|
|
8085
|
+
}
|
|
8086
|
+
function convertRemoteValidateExpression(expr, action) {
|
|
8087
|
+
return action === TailorDBType_PermitAction.DENY && expr.startsWith("!") ? expr.slice(1) : expr;
|
|
8088
|
+
}
|
|
8089
|
+
function convertRemoteSettingsToSnapshot(remoteSettings, expectedSettings) {
|
|
8090
|
+
const settings = {};
|
|
8091
|
+
if (remoteSettings?.aggregation) settings.aggregation = true;
|
|
8092
|
+
if (remoteSettings?.bulkUpsert) settings.bulkUpsert = true;
|
|
8093
|
+
if (remoteSettings?.publishRecordEvents) settings.publishEvents = true;
|
|
8094
|
+
const disabled = remoteSettings?.disableGqlOperations;
|
|
8095
|
+
if (disabled) {
|
|
8096
|
+
const hasDisabledOperation = disabled.create || disabled.update || disabled.delete || disabled.read;
|
|
8097
|
+
if (expectedSettings?.gqlOperations !== void 0 || hasDisabledOperation) settings.gqlOperations = {
|
|
8098
|
+
create: !disabled.create,
|
|
8099
|
+
update: !disabled.update,
|
|
8100
|
+
delete: !disabled.delete,
|
|
8101
|
+
read: !disabled.read
|
|
7990
8102
|
};
|
|
7991
|
-
if (remoteField.scale !== void 0) config.scale = remoteField.scale;
|
|
7992
|
-
fields[fieldName] = config;
|
|
7993
8103
|
}
|
|
7994
|
-
return
|
|
8104
|
+
return Object.keys(settings).length > 0 ? settings : void 0;
|
|
7995
8105
|
}
|
|
7996
|
-
function
|
|
8106
|
+
function convertRemoteIndexesToSnapshot(remoteIndexes) {
|
|
8107
|
+
const indexes = createSnapshotRecord();
|
|
8108
|
+
for (const [indexName, indexConfig] of Object.entries(remoteIndexes ?? {})) indexes[indexName] = {
|
|
8109
|
+
fields: indexConfig.fieldNames,
|
|
8110
|
+
...indexConfig.unique && { unique: true }
|
|
8111
|
+
};
|
|
8112
|
+
return Object.keys(indexes).length > 0 ? indexes : void 0;
|
|
8113
|
+
}
|
|
8114
|
+
function convertRemoteFilesToSnapshot(remoteFiles) {
|
|
8115
|
+
const files = createSnapshotRecord();
|
|
8116
|
+
for (const [fileName, fileConfig] of Object.entries(remoteFiles ?? {})) files[fileName] = fileConfig.description || "";
|
|
8117
|
+
return Object.keys(files).length > 0 ? files : void 0;
|
|
8118
|
+
}
|
|
8119
|
+
function convertRemoteRelationshipToSnapshot(relationship, direction) {
|
|
8120
|
+
return direction === "forward" ? {
|
|
8121
|
+
targetType: relationship.refType,
|
|
8122
|
+
targetField: relationship.srcField,
|
|
8123
|
+
sourceField: relationship.refField,
|
|
8124
|
+
isArray: relationship.array,
|
|
8125
|
+
description: relationship.description || ""
|
|
8126
|
+
} : {
|
|
8127
|
+
targetType: relationship.refType,
|
|
8128
|
+
targetField: relationship.refField,
|
|
8129
|
+
sourceField: relationship.srcField,
|
|
8130
|
+
isArray: relationship.array,
|
|
8131
|
+
description: relationship.description || ""
|
|
8132
|
+
};
|
|
8133
|
+
}
|
|
8134
|
+
function remoteRelationshipMatchesExpectedDirection(relationship, expected, direction) {
|
|
8135
|
+
const converted = convertRemoteRelationshipToSnapshot(relationship, direction);
|
|
8136
|
+
return converted.targetType === expected.targetType && converted.targetField === expected.targetField && converted.sourceField === expected.sourceField && converted.isArray === expected.isArray;
|
|
8137
|
+
}
|
|
8138
|
+
function inferRemoteRelationshipDirection(relationshipName, relationship, expectedType) {
|
|
8139
|
+
const expectedForward = expectedType?.forwardRelationships?.[relationshipName];
|
|
8140
|
+
const expectedBackward = expectedType?.backwardRelationships?.[relationshipName];
|
|
8141
|
+
if (expectedForward && !expectedBackward) return "forward";
|
|
8142
|
+
if (expectedBackward && !expectedForward) return "backward";
|
|
8143
|
+
if (expectedForward && remoteRelationshipMatchesExpectedDirection(relationship, expectedForward, "forward")) return "forward";
|
|
8144
|
+
if (expectedBackward && remoteRelationshipMatchesExpectedDirection(relationship, expectedBackward, "backward")) return "backward";
|
|
8145
|
+
return relationship.array ? "backward" : "forward";
|
|
8146
|
+
}
|
|
8147
|
+
function convertRemoteRelationshipsToSnapshot(remoteRelationships, expectedType) {
|
|
8148
|
+
const forwardRelationships = createSnapshotRecord();
|
|
8149
|
+
const backwardRelationships = createSnapshotRecord();
|
|
8150
|
+
for (const [relationshipName, relationship] of Object.entries(remoteRelationships ?? {})) {
|
|
8151
|
+
const direction = inferRemoteRelationshipDirection(relationshipName, relationship, expectedType);
|
|
8152
|
+
if (direction === "forward") forwardRelationships[relationshipName] = convertRemoteRelationshipToSnapshot(relationship, direction);
|
|
8153
|
+
else backwardRelationships[relationshipName] = convertRemoteRelationshipToSnapshot(relationship, direction);
|
|
8154
|
+
}
|
|
8155
|
+
return {
|
|
8156
|
+
...Object.keys(forwardRelationships).length > 0 && { forwardRelationships },
|
|
8157
|
+
...Object.keys(backwardRelationships).length > 0 && { backwardRelationships }
|
|
8158
|
+
};
|
|
8159
|
+
}
|
|
8160
|
+
const REMOTE_PERMISSION_PERMITS = /* @__PURE__ */ new Map([[TailorDBType_Permission_Permit.ALLOW, "allow"], [TailorDBType_Permission_Permit.DENY, "deny"]]);
|
|
8161
|
+
const REMOTE_PERMISSION_OPERATORS = /* @__PURE__ */ new Map([
|
|
8162
|
+
[TailorDBType_Permission_Operator.EQ, "eq"],
|
|
8163
|
+
[TailorDBType_Permission_Operator.NE, "ne"],
|
|
8164
|
+
[TailorDBType_Permission_Operator.IN, "in"],
|
|
8165
|
+
[TailorDBType_Permission_Operator.NIN, "nin"],
|
|
8166
|
+
[TailorDBType_Permission_Operator.HAS_ANY, "hasAny"],
|
|
8167
|
+
[TailorDBType_Permission_Operator.NHAS_ANY, "nhasAny"]
|
|
8168
|
+
]);
|
|
8169
|
+
function convertRemotePermit(permit, source) {
|
|
8170
|
+
const converted = REMOTE_PERMISSION_PERMITS.get(permit);
|
|
8171
|
+
if (converted) return converted;
|
|
8172
|
+
throw new Error(`Unsupported ${source} permission permit: ${permit}`);
|
|
8173
|
+
}
|
|
8174
|
+
function convertRemoteOperator(operator, source) {
|
|
8175
|
+
const converted = REMOTE_PERMISSION_OPERATORS.get(operator);
|
|
8176
|
+
if (converted) return converted;
|
|
8177
|
+
throw new Error(`Unsupported ${source} permission operator: ${operator}`);
|
|
8178
|
+
}
|
|
8179
|
+
function convertRemoteValueOperand(operand) {
|
|
8180
|
+
switch (operand?.kind.case) {
|
|
8181
|
+
case "userField": return { user: operand.kind.value };
|
|
8182
|
+
case "recordField": return { record: operand.kind.value };
|
|
8183
|
+
case "oldRecordField": return { oldRecord: operand.kind.value };
|
|
8184
|
+
case "newRecordField": return { newRecord: operand.kind.value };
|
|
8185
|
+
case "value": return toJson(ValueSchema, operand.kind.value);
|
|
8186
|
+
default: throw new Error("Unsupported permission operand");
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
function convertRemoteRecordCondition(condition) {
|
|
8190
|
+
return [
|
|
8191
|
+
convertRemoteValueOperand(condition.left),
|
|
8192
|
+
convertRemoteOperator(condition.operator, "record"),
|
|
8193
|
+
convertRemoteValueOperand(condition.right)
|
|
8194
|
+
];
|
|
8195
|
+
}
|
|
8196
|
+
function convertRemoteGqlCondition(condition) {
|
|
8197
|
+
return [
|
|
8198
|
+
convertRemoteValueOperand(condition.left),
|
|
8199
|
+
convertRemoteOperator(condition.operator, "GQL"),
|
|
8200
|
+
convertRemoteValueOperand(condition.right)
|
|
8201
|
+
];
|
|
8202
|
+
}
|
|
8203
|
+
function convertRemoteRecordPolicy(policy) {
|
|
8204
|
+
return {
|
|
8205
|
+
conditions: policy.conditions.map(convertRemoteRecordCondition),
|
|
8206
|
+
permit: convertRemotePermit(policy.permit, "record"),
|
|
8207
|
+
...policy.description && { description: policy.description }
|
|
8208
|
+
};
|
|
8209
|
+
}
|
|
8210
|
+
function convertRemoteRecordPermissionToSnapshot(permission) {
|
|
8211
|
+
const recordPermission = {
|
|
8212
|
+
create: permission?.create.map(convertRemoteRecordPolicy) ?? [],
|
|
8213
|
+
read: permission?.read.map(convertRemoteRecordPolicy) ?? [],
|
|
8214
|
+
update: permission?.update.map(convertRemoteRecordPolicy) ?? [],
|
|
8215
|
+
delete: permission?.delete.map(convertRemoteRecordPolicy) ?? []
|
|
8216
|
+
};
|
|
8217
|
+
return Object.values(recordPermission).some((policies) => policies.length > 0) ? recordPermission : void 0;
|
|
8218
|
+
}
|
|
8219
|
+
function convertRemoteGqlAction(action) {
|
|
8220
|
+
switch (action) {
|
|
8221
|
+
case TailorDBGQLPermission_Action.ALL: return "all";
|
|
8222
|
+
case TailorDBGQLPermission_Action.CREATE: return "create";
|
|
8223
|
+
case TailorDBGQLPermission_Action.READ: return "read";
|
|
8224
|
+
case TailorDBGQLPermission_Action.UPDATE: return "update";
|
|
8225
|
+
case TailorDBGQLPermission_Action.DELETE: return "delete";
|
|
8226
|
+
case TailorDBGQLPermission_Action.AGGREGATE: return "aggregate";
|
|
8227
|
+
case TailorDBGQLPermission_Action.BULK_UPSERT: return "bulkUpsert";
|
|
8228
|
+
default: throw new Error(`Unsupported GQL permission action: ${action}`);
|
|
8229
|
+
}
|
|
8230
|
+
}
|
|
8231
|
+
function convertRemoteGqlPermissionToSnapshot(permission) {
|
|
8232
|
+
const policies = permission?.policies.map((policy) => ({
|
|
8233
|
+
conditions: policy.conditions.map(convertRemoteGqlCondition),
|
|
8234
|
+
actions: policy.actions.map(convertRemoteGqlAction),
|
|
8235
|
+
permit: convertRemotePermit(policy.permit, "GQL"),
|
|
8236
|
+
...policy.description && { description: policy.description }
|
|
8237
|
+
})) ?? [];
|
|
8238
|
+
return policies.length > 0 ? policies : void 0;
|
|
8239
|
+
}
|
|
8240
|
+
function convertRemoteTypeToSnapshot(remoteType, expectedType) {
|
|
8241
|
+
const settings = convertRemoteSettingsToSnapshot(remoteType.schema?.settings, expectedType?.settings);
|
|
8242
|
+
const relationships = convertRemoteRelationshipsToSnapshot(remoteType.schema?.relationships, expectedType);
|
|
8243
|
+
const recordPermission = convertRemoteRecordPermissionToSnapshot(remoteType.schema?.permission);
|
|
7997
8244
|
const snapshotType = {
|
|
7998
8245
|
name: remoteType.name,
|
|
7999
8246
|
pluralForm: remoteType.schema?.settings?.pluralForm || inflection.pluralize(remoteType.name),
|
|
8000
|
-
fields: convertRemoteFieldsToSnapshot(remoteType)
|
|
8247
|
+
fields: convertRemoteFieldsToSnapshot(remoteType),
|
|
8248
|
+
...settings && { settings },
|
|
8249
|
+
...relationships
|
|
8001
8250
|
};
|
|
8002
8251
|
if (remoteType.schema?.description) snapshotType.description = remoteType.schema.description;
|
|
8252
|
+
const indexes = convertRemoteIndexesToSnapshot(remoteType.schema?.indexes);
|
|
8253
|
+
if (indexes) snapshotType.indexes = indexes;
|
|
8254
|
+
const files = convertRemoteFilesToSnapshot(remoteType.schema?.files);
|
|
8255
|
+
if (files) snapshotType.files = files;
|
|
8256
|
+
if (recordPermission) snapshotType.permissions = { record: recordPermission };
|
|
8003
8257
|
return snapshotType;
|
|
8004
8258
|
}
|
|
8005
8259
|
/**
|
|
8006
8260
|
* Convert remote TailorDB types into the normalized snapshot shape used by drift checks.
|
|
8007
8261
|
* @param {ProtoTailorDBType[]} remoteTypes - Remote TailorDB types from the API
|
|
8008
8262
|
* @param {string} namespace - Namespace for the reconstructed snapshot
|
|
8263
|
+
* @param {readonly RemoteGqlPermission[]} remoteGqlPermissions - Remote GQL permissions for the namespace
|
|
8264
|
+
* @param {SchemaSnapshot} expectedSnapshot - Optional snapshot used to disambiguate remote relationship direction
|
|
8009
8265
|
* @returns {NormalizedSchemaSnapshot} Normalized snapshot-shaped remote state
|
|
8010
8266
|
*/
|
|
8011
|
-
function createSnapshotFromRemoteTypes(remoteTypes, namespace) {
|
|
8267
|
+
function createSnapshotFromRemoteTypes(remoteTypes, namespace, remoteGqlPermissions = [], expectedSnapshot) {
|
|
8012
8268
|
const types = createSnapshotRecord();
|
|
8013
|
-
for (const remoteType of remoteTypes) types[remoteType.name] = convertRemoteTypeToSnapshot(remoteType);
|
|
8269
|
+
for (const remoteType of remoteTypes) types[remoteType.name] = convertRemoteTypeToSnapshot(remoteType, expectedSnapshot?.types[remoteType.name]);
|
|
8270
|
+
for (const permission of remoteGqlPermissions) {
|
|
8271
|
+
const { typeName } = permission;
|
|
8272
|
+
const snapshotType = types[typeName];
|
|
8273
|
+
if (!snapshotType) continue;
|
|
8274
|
+
const gqlPermission = convertRemoteGqlPermissionToSnapshot(permission.permission);
|
|
8275
|
+
if (!gqlPermission) continue;
|
|
8276
|
+
snapshotType.permissions = {
|
|
8277
|
+
...snapshotType.permissions,
|
|
8278
|
+
gql: gqlPermission
|
|
8279
|
+
};
|
|
8280
|
+
}
|
|
8014
8281
|
return normalizeSchemaSnapshot({
|
|
8015
8282
|
version: 1,
|
|
8016
8283
|
namespace,
|
|
@@ -8018,6 +8285,107 @@ function createSnapshotFromRemoteTypes(remoteTypes, namespace) {
|
|
|
8018
8285
|
types
|
|
8019
8286
|
});
|
|
8020
8287
|
}
|
|
8288
|
+
function fieldDifferenceValue(value) {
|
|
8289
|
+
if (value === void 0 || value === "") return "none";
|
|
8290
|
+
return String(value);
|
|
8291
|
+
}
|
|
8292
|
+
function fieldDifferenceKey(prefix, key) {
|
|
8293
|
+
return prefix ? `${prefix}.${key}` : key;
|
|
8294
|
+
}
|
|
8295
|
+
function addFieldDifference(differences, prefix, key, remoteValue, snapshotValue) {
|
|
8296
|
+
if (remoteValue === snapshotValue) return;
|
|
8297
|
+
differences.push(`${fieldDifferenceKey(prefix, key)}: remote=${fieldDifferenceValue(remoteValue)}, expected=${fieldDifferenceValue(snapshotValue)}`);
|
|
8298
|
+
}
|
|
8299
|
+
function addBooleanFieldDifference(differences, prefix, key, remoteField, snapshotField) {
|
|
8300
|
+
addFieldDifference(differences, prefix, key, remoteField[key] ?? false, snapshotField[key] ?? false);
|
|
8301
|
+
}
|
|
8302
|
+
function addAllowedValuesDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8303
|
+
const remoteAllowed = remoteField.allowedValues ?? [];
|
|
8304
|
+
const snapshotAllowed = snapshotField.allowedValues ?? [];
|
|
8305
|
+
if (remoteAllowed.length !== snapshotAllowed.length) {
|
|
8306
|
+
differences.push(`${fieldDifferenceKey(prefix, "allowedValues")} count: remote=${remoteAllowed.length}, expected=${snapshotAllowed.length}`);
|
|
8307
|
+
return;
|
|
8308
|
+
}
|
|
8309
|
+
const snapshotAllowedValues = new Map(snapshotAllowed.map((v) => [v.value, v.description]));
|
|
8310
|
+
for (const value of remoteAllowed) {
|
|
8311
|
+
if (!snapshotAllowedValues.has(value.value)) {
|
|
8312
|
+
differences.push(`${fieldDifferenceKey(prefix, "allowedValues")}: remote has '${value.value}' not in snapshot`);
|
|
8313
|
+
return;
|
|
8314
|
+
}
|
|
8315
|
+
const snapshotDescription = snapshotAllowedValues.get(value.value);
|
|
8316
|
+
if ((value.description ?? "") !== (snapshotDescription ?? "")) {
|
|
8317
|
+
addFieldDifference(differences, prefix, `allowedValues.${value.value}.description`, value.description ?? "", snapshotDescription ?? "");
|
|
8318
|
+
return;
|
|
8319
|
+
}
|
|
8320
|
+
}
|
|
8321
|
+
const remoteAllowedValues = new Set(remoteAllowed.map((v) => v.value));
|
|
8322
|
+
for (const value of snapshotAllowed) if (!remoteAllowedValues.has(value.value)) {
|
|
8323
|
+
differences.push(`${fieldDifferenceKey(prefix, "allowedValues")}: snapshot has '${value.value}' not in remote`);
|
|
8324
|
+
return;
|
|
8325
|
+
}
|
|
8326
|
+
}
|
|
8327
|
+
function addHooksDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8328
|
+
addFieldDifference(differences, prefix, "hooks.create", remoteField.hooks?.create?.expr ?? "", snapshotField.hooks?.create?.expr ?? "");
|
|
8329
|
+
addFieldDifference(differences, prefix, "hooks.update", remoteField.hooks?.update?.expr ?? "", snapshotField.hooks?.update?.expr ?? "");
|
|
8330
|
+
}
|
|
8331
|
+
function addValidationDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8332
|
+
const remoteValidate = remoteField.validate ?? [];
|
|
8333
|
+
const snapshotValidate = snapshotField.validate ?? [];
|
|
8334
|
+
if (remoteValidate.length !== snapshotValidate.length) differences.push(`${fieldDifferenceKey(prefix, "validate")} count: remote=${remoteValidate.length}, expected=${snapshotValidate.length}`);
|
|
8335
|
+
const commonLength = Math.min(remoteValidate.length, snapshotValidate.length);
|
|
8336
|
+
for (let index = 0; index < commonLength; index++) {
|
|
8337
|
+
const remoteValidation = assertDefined(remoteValidate[index], `remoteValidate missing index ${index}`);
|
|
8338
|
+
const snapshotValidation = assertDefined(snapshotValidate[index], `snapshotValidate missing index ${index}`);
|
|
8339
|
+
addFieldDifference(differences, prefix, `validate[${index}].script`, remoteValidation.script?.expr ?? "", snapshotValidation.script?.expr ?? "");
|
|
8340
|
+
addFieldDifference(differences, prefix, `validate[${index}].errorMessage`, remoteValidation.errorMessage, snapshotValidation.errorMessage);
|
|
8341
|
+
}
|
|
8342
|
+
}
|
|
8343
|
+
function addSerialDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8344
|
+
addFieldDifference(differences, prefix, "serial.start", remoteField.serial?.start, snapshotField.serial?.start);
|
|
8345
|
+
addFieldDifference(differences, prefix, "serial.maxValue", remoteField.serial?.maxValue, snapshotField.serial?.maxValue);
|
|
8346
|
+
addFieldDifference(differences, prefix, "serial.format", remoteField.serial?.format ?? "", snapshotField.serial?.format ?? "");
|
|
8347
|
+
}
|
|
8348
|
+
function addNestedFieldDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8349
|
+
const remoteFields = remoteField.fields ?? {};
|
|
8350
|
+
const snapshotFields = snapshotField.fields ?? {};
|
|
8351
|
+
const remoteFieldNames = Object.keys(remoteFields);
|
|
8352
|
+
const snapshotFieldNames = Object.keys(snapshotFields);
|
|
8353
|
+
if (remoteFieldNames.length !== snapshotFieldNames.length) differences.push(`${fieldDifferenceKey(prefix, "fields")} count: remote=${remoteFieldNames.length}, expected=${snapshotFieldNames.length}`);
|
|
8354
|
+
for (const fieldName of remoteFieldNames) {
|
|
8355
|
+
const remoteNestedField = remoteFields[fieldName];
|
|
8356
|
+
const snapshotNestedField = snapshotFields[fieldName];
|
|
8357
|
+
const nestedPrefix = fieldDifferenceKey(prefix, `fields.${fieldName}`);
|
|
8358
|
+
if (!snapshotNestedField) {
|
|
8359
|
+
differences.push(`${nestedPrefix}: exists in remote but not snapshot`);
|
|
8360
|
+
continue;
|
|
8361
|
+
}
|
|
8362
|
+
addFieldDifferences(differences, nestedPrefix, assertDefined(remoteNestedField, `remote field "${fieldName}" missing`), snapshotNestedField);
|
|
8363
|
+
}
|
|
8364
|
+
for (const fieldName of snapshotFieldNames) {
|
|
8365
|
+
if (remoteFields[fieldName]) continue;
|
|
8366
|
+
differences.push(`${fieldDifferenceKey(prefix, `fields.${fieldName}`)}: exists in snapshot but not remote`);
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
function addFieldDifferences(differences, prefix, remoteField, snapshotField) {
|
|
8370
|
+
addFieldDifference(differences, prefix, "type", remoteField.type, snapshotField.type);
|
|
8371
|
+
addFieldDifference(differences, prefix, "required", remoteField.required, snapshotField.required);
|
|
8372
|
+
for (const key of [
|
|
8373
|
+
"array",
|
|
8374
|
+
"index",
|
|
8375
|
+
"unique",
|
|
8376
|
+
"foreignKey",
|
|
8377
|
+
"vector"
|
|
8378
|
+
]) addBooleanFieldDifference(differences, prefix, key, remoteField, snapshotField);
|
|
8379
|
+
addFieldDifference(differences, prefix, "foreignKeyType", remoteField.foreignKeyType, snapshotField.foreignKeyType);
|
|
8380
|
+
addFieldDifference(differences, prefix, "foreignKeyField", remoteField.foreignKeyField, snapshotField.foreignKeyField);
|
|
8381
|
+
addFieldDifference(differences, prefix, "description", remoteField.description ?? "", snapshotField.description ?? "");
|
|
8382
|
+
addAllowedValuesDifferences(differences, prefix, remoteField, snapshotField);
|
|
8383
|
+
addHooksDifferences(differences, prefix, remoteField, snapshotField);
|
|
8384
|
+
addValidationDifferences(differences, prefix, remoteField, snapshotField);
|
|
8385
|
+
addSerialDifferences(differences, prefix, remoteField, snapshotField);
|
|
8386
|
+
addFieldDifference(differences, prefix, "scale", remoteField.scale, snapshotField.scale);
|
|
8387
|
+
addNestedFieldDifferences(differences, prefix, remoteField, snapshotField);
|
|
8388
|
+
}
|
|
8021
8389
|
/**
|
|
8022
8390
|
* Compare a single field between remote and snapshot
|
|
8023
8391
|
* @param {string} typeName - Name of the type
|
|
@@ -8028,37 +8396,7 @@ function createSnapshotFromRemoteTypes(remoteTypes, namespace) {
|
|
|
8028
8396
|
*/
|
|
8029
8397
|
function compareFields(typeName, fieldName, remoteField, snapshotField) {
|
|
8030
8398
|
const differences = [];
|
|
8031
|
-
|
|
8032
|
-
if (remoteField.required !== snapshotField.required) differences.push(`required: remote=${remoteField.required}, expected=${snapshotField.required}`);
|
|
8033
|
-
const remoteArray = remoteField.array ?? false;
|
|
8034
|
-
const snapshotArray = snapshotField.array ?? false;
|
|
8035
|
-
if (remoteArray !== snapshotArray) differences.push(`array: remote=${remoteArray}, expected=${snapshotArray}`);
|
|
8036
|
-
const remoteUnique = remoteField.unique ?? false;
|
|
8037
|
-
const snapshotUnique = snapshotField.unique ?? false;
|
|
8038
|
-
if (remoteUnique !== snapshotUnique) differences.push(`unique: remote=${remoteUnique}, expected=${snapshotUnique}`);
|
|
8039
|
-
const remoteFk = remoteField.foreignKey ?? false;
|
|
8040
|
-
const snapshotFk = snapshotField.foreignKey ?? false;
|
|
8041
|
-
if (remoteFk !== snapshotFk) differences.push(`foreignKey: remote=${remoteFk}, expected=${snapshotFk}`);
|
|
8042
|
-
if (remoteField.foreignKeyType !== snapshotField.foreignKeyType) differences.push(`foreignKeyType: remote=${remoteField.foreignKeyType ?? "none"}, expected=${snapshotField.foreignKeyType ?? "none"}`);
|
|
8043
|
-
const remoteAllowed = remoteField.allowedValues ?? [];
|
|
8044
|
-
const snapshotAllowed = snapshotField.allowedValues ?? [];
|
|
8045
|
-
const remoteAllowedValues = new Set(remoteAllowed.map((v) => v.value));
|
|
8046
|
-
const snapshotAllowedValues = new Set(snapshotAllowed.map((v) => v.value));
|
|
8047
|
-
if (remoteAllowedValues.size !== snapshotAllowedValues.size) differences.push(`allowedValues count: remote=${remoteAllowedValues.size}, expected=${snapshotAllowedValues.size}`);
|
|
8048
|
-
else {
|
|
8049
|
-
for (const v of remoteAllowedValues) if (!snapshotAllowedValues.has(v)) {
|
|
8050
|
-
differences.push(`allowedValues: remote has '${v}' not in snapshot`);
|
|
8051
|
-
break;
|
|
8052
|
-
}
|
|
8053
|
-
for (const v of snapshotAllowedValues) if (!remoteAllowedValues.has(v)) {
|
|
8054
|
-
differences.push(`allowedValues: snapshot has '${v}' not in remote`);
|
|
8055
|
-
break;
|
|
8056
|
-
}
|
|
8057
|
-
}
|
|
8058
|
-
const remoteVector = remoteField.vector ?? false;
|
|
8059
|
-
const snapshotVector = snapshotField.vector ?? false;
|
|
8060
|
-
if (remoteVector !== snapshotVector) differences.push(`vector: remote=${remoteVector}, expected=${snapshotVector}`);
|
|
8061
|
-
if (remoteField.scale !== snapshotField.scale) differences.push(`scale: remote=${remoteField.scale}, expected=${snapshotField.scale}`);
|
|
8399
|
+
addFieldDifferences(differences, "", remoteField, snapshotField);
|
|
8062
8400
|
if (differences.length > 0) return {
|
|
8063
8401
|
typeName,
|
|
8064
8402
|
kind: "field_mismatch",
|
|
@@ -8075,53 +8413,136 @@ const SYSTEM_FIELDS = /* @__PURE__ */ new Set(["id"]);
|
|
|
8075
8413
|
* Compare remote TailorDB types with a local snapshot
|
|
8076
8414
|
* @param {ProtoTailorDBType[]} remoteTypes - Remote types from listParsedTailorDBTypes API
|
|
8077
8415
|
* @param {SchemaSnapshot} snapshot - Local schema snapshot
|
|
8416
|
+
* @param {readonly RemoteGqlPermission[]} remoteGqlPermissions - Remote GQL permissions for the namespace
|
|
8078
8417
|
* @returns {SchemaDrift[]} List of drifts detected
|
|
8079
8418
|
*/
|
|
8080
|
-
function compareRemoteWithSnapshot(remoteTypes, snapshot) {
|
|
8081
|
-
return compareNormalizedRemoteWithSnapshot(createSnapshotFromRemoteTypes(remoteTypes, snapshot.namespace),
|
|
8419
|
+
function compareRemoteWithSnapshot(remoteTypes, snapshot, remoteGqlPermissions = []) {
|
|
8420
|
+
return compareNormalizedRemoteWithSnapshot(createRemoteComparableSnapshot(createSnapshotFromRemoteTypes(remoteTypes, snapshot.namespace, remoteGqlPermissions, snapshot)), createRemoteComparableSnapshot(snapshot));
|
|
8082
8421
|
}
|
|
8083
|
-
function
|
|
8084
|
-
const
|
|
8085
|
-
const
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8422
|
+
function createRemoteComparableSnapshot(snapshot) {
|
|
8423
|
+
const types = createSnapshotRecord();
|
|
8424
|
+
for (const [typeName, type] of Object.entries(snapshot.types)) {
|
|
8425
|
+
const fields = createSnapshotRecord();
|
|
8426
|
+
for (const [fieldName, field] of Object.entries(type.fields)) {
|
|
8427
|
+
if (SYSTEM_FIELDS.has(fieldName)) continue;
|
|
8428
|
+
fields[fieldName] = field;
|
|
8429
|
+
}
|
|
8430
|
+
types[typeName] = {
|
|
8431
|
+
...type,
|
|
8432
|
+
fields
|
|
8433
|
+
};
|
|
8434
|
+
}
|
|
8435
|
+
return normalizeSchemaSnapshot({
|
|
8436
|
+
...snapshot,
|
|
8437
|
+
types
|
|
8097
8438
|
});
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8439
|
+
}
|
|
8440
|
+
function fieldDriftFromChange(change) {
|
|
8441
|
+
return compareFields(change.typeName, change.fieldName, change.before, change.after) ?? {
|
|
8442
|
+
typeName: change.typeName,
|
|
8443
|
+
kind: "field_mismatch",
|
|
8444
|
+
fieldName: change.fieldName,
|
|
8445
|
+
details: `Field '${change.fieldName}' differs between remote and snapshot`
|
|
8446
|
+
};
|
|
8447
|
+
}
|
|
8448
|
+
function schemaDriftFromDiffChange(change) {
|
|
8449
|
+
switch (change.kind) {
|
|
8450
|
+
case "type_added": return {
|
|
8451
|
+
typeName: change.typeName,
|
|
8452
|
+
kind: "type_missing_remote",
|
|
8453
|
+
details: `Type '${change.typeName}' exists in snapshot but not in remote`
|
|
8454
|
+
};
|
|
8455
|
+
case "type_removed": return {
|
|
8456
|
+
typeName: change.typeName,
|
|
8457
|
+
kind: "type_missing_local",
|
|
8458
|
+
details: `Type '${change.typeName}' exists in remote but not in snapshot`
|
|
8459
|
+
};
|
|
8460
|
+
case "type_settings_modified":
|
|
8461
|
+
case "type_modified": return {
|
|
8462
|
+
typeName: change.typeName,
|
|
8463
|
+
kind: "type_settings_mismatch",
|
|
8464
|
+
details: change.reason ?? "Type settings differ between remote and snapshot"
|
|
8465
|
+
};
|
|
8466
|
+
case "field_added": return {
|
|
8467
|
+
typeName: change.typeName,
|
|
8108
8468
|
kind: "field_missing_remote",
|
|
8109
|
-
fieldName,
|
|
8110
|
-
details: `Field '${fieldName}' exists in snapshot but not in remote`
|
|
8111
|
-
}
|
|
8112
|
-
|
|
8113
|
-
typeName,
|
|
8469
|
+
fieldName: change.fieldName,
|
|
8470
|
+
details: `Field '${change.fieldName}' exists in snapshot but not in remote`
|
|
8471
|
+
};
|
|
8472
|
+
case "field_removed": return {
|
|
8473
|
+
typeName: change.typeName,
|
|
8114
8474
|
kind: "field_missing_local",
|
|
8115
|
-
fieldName,
|
|
8116
|
-
details: `Field '${fieldName}' exists in remote but not in snapshot`
|
|
8117
|
-
}
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8475
|
+
fieldName: change.fieldName,
|
|
8476
|
+
details: `Field '${change.fieldName}' exists in remote but not in snapshot`
|
|
8477
|
+
};
|
|
8478
|
+
case "field_modified": return fieldDriftFromChange(change);
|
|
8479
|
+
case "index_added": return {
|
|
8480
|
+
typeName: change.typeName,
|
|
8481
|
+
kind: "index_missing_remote",
|
|
8482
|
+
indexName: change.indexName,
|
|
8483
|
+
details: `Index '${change.indexName}' exists in snapshot but not in remote`
|
|
8484
|
+
};
|
|
8485
|
+
case "index_removed": return {
|
|
8486
|
+
typeName: change.typeName,
|
|
8487
|
+
kind: "index_missing_local",
|
|
8488
|
+
indexName: change.indexName,
|
|
8489
|
+
details: `Index '${change.indexName}' exists in remote but not in snapshot`
|
|
8490
|
+
};
|
|
8491
|
+
case "index_modified": return {
|
|
8492
|
+
typeName: change.typeName,
|
|
8493
|
+
kind: "index_mismatch",
|
|
8494
|
+
indexName: change.indexName,
|
|
8495
|
+
details: change.reason ?? `Index '${change.indexName}' differs between remote and snapshot`
|
|
8496
|
+
};
|
|
8497
|
+
case "file_added": return {
|
|
8498
|
+
typeName: change.typeName,
|
|
8499
|
+
kind: "file_missing_remote",
|
|
8500
|
+
fileName: change.fieldName,
|
|
8501
|
+
details: `File '${change.fieldName}' exists in snapshot but not in remote`
|
|
8502
|
+
};
|
|
8503
|
+
case "file_removed": return {
|
|
8504
|
+
typeName: change.typeName,
|
|
8505
|
+
kind: "file_missing_local",
|
|
8506
|
+
fileName: change.fieldName,
|
|
8507
|
+
details: `File '${change.fieldName}' exists in remote but not in snapshot`
|
|
8508
|
+
};
|
|
8509
|
+
case "file_modified": return {
|
|
8510
|
+
typeName: change.typeName,
|
|
8511
|
+
kind: "file_mismatch",
|
|
8512
|
+
fileName: change.fieldName,
|
|
8513
|
+
details: change.reason ?? `File '${change.fieldName}' differs between remote and snapshot`
|
|
8514
|
+
};
|
|
8515
|
+
case "relationship_added": return {
|
|
8516
|
+
typeName: change.typeName,
|
|
8517
|
+
kind: "relationship_missing_remote",
|
|
8518
|
+
relationshipName: change.relationshipName,
|
|
8519
|
+
relationshipType: change.relationshipType,
|
|
8520
|
+
details: `Relationship '${change.relationshipName}' exists in snapshot but not in remote`
|
|
8521
|
+
};
|
|
8522
|
+
case "relationship_removed": return {
|
|
8523
|
+
typeName: change.typeName,
|
|
8524
|
+
kind: "relationship_missing_local",
|
|
8525
|
+
relationshipName: change.relationshipName,
|
|
8526
|
+
relationshipType: change.relationshipType,
|
|
8527
|
+
details: `Relationship '${change.relationshipName}' exists in remote but not in snapshot`
|
|
8528
|
+
};
|
|
8529
|
+
case "relationship_modified": return {
|
|
8530
|
+
typeName: change.typeName,
|
|
8531
|
+
kind: "relationship_mismatch",
|
|
8532
|
+
relationshipName: change.relationshipName,
|
|
8533
|
+
relationshipType: change.relationshipType,
|
|
8534
|
+
details: change.reason ?? `Relationship '${change.relationshipName}' differs between remote and snapshot`
|
|
8535
|
+
};
|
|
8536
|
+
case "permission_modified": return {
|
|
8537
|
+
typeName: change.typeName,
|
|
8538
|
+
kind: "permission_mismatch",
|
|
8539
|
+
details: change.reason ?? "Permissions differ between remote and snapshot"
|
|
8540
|
+
};
|
|
8541
|
+
default: throw new Error("Unsupported diff change");
|
|
8123
8542
|
}
|
|
8124
|
-
|
|
8543
|
+
}
|
|
8544
|
+
function compareNormalizedRemoteWithSnapshot(remoteSnapshot, snapshot) {
|
|
8545
|
+
return compareNormalizedSnapshots(remoteSnapshot, snapshot).changes.map(schemaDriftFromDiffChange);
|
|
8125
8546
|
}
|
|
8126
8547
|
/**
|
|
8127
8548
|
* Format schema drifts for display
|
|
@@ -8140,7 +8561,12 @@ function formatSchemaDrifts(drifts) {
|
|
|
8140
8561
|
for (const [typeName, typeDrifts] of driftsByType) {
|
|
8141
8562
|
lines.push(` Type '${typeName}':`);
|
|
8142
8563
|
for (const drift of typeDrifts) if (drift.fieldName) lines.push(` - Field '${drift.fieldName}': ${drift.details}`);
|
|
8143
|
-
else lines.push(` - ${drift.details}`);
|
|
8564
|
+
else if (drift.indexName) lines.push(` - Index '${drift.indexName}': ${drift.details}`);
|
|
8565
|
+
else if (drift.fileName) lines.push(` - File '${drift.fileName}': ${drift.details}`);
|
|
8566
|
+
else if (drift.relationshipName) {
|
|
8567
|
+
const relationshipType = drift.relationshipType ? ` (${drift.relationshipType})` : "";
|
|
8568
|
+
lines.push(` - Relationship${relationshipType} '${drift.relationshipName}': ${drift.details}`);
|
|
8569
|
+
} else lines.push(` - ${drift.details}`);
|
|
8144
8570
|
}
|
|
8145
8571
|
return lines.join("\n");
|
|
8146
8572
|
}
|
|
@@ -9229,6 +9655,77 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
|
|
|
9229
9655
|
}
|
|
9230
9656
|
});
|
|
9231
9657
|
}
|
|
9658
|
+
async function fetchRemoteGqlPermissions(client, workspaceId, namespace) {
|
|
9659
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
9660
|
+
try {
|
|
9661
|
+
const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
|
|
9662
|
+
workspaceId,
|
|
9663
|
+
namespaceName: namespace,
|
|
9664
|
+
pageToken,
|
|
9665
|
+
pageSize: maxPageSize
|
|
9666
|
+
});
|
|
9667
|
+
return [permissions, nextPageToken];
|
|
9668
|
+
} catch (error) {
|
|
9669
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
|
|
9670
|
+
throw error;
|
|
9671
|
+
}
|
|
9672
|
+
});
|
|
9673
|
+
}
|
|
9674
|
+
function definedWhenNotEmpty(value) {
|
|
9675
|
+
return Object.keys(value).length > 0 ? value : void 0;
|
|
9676
|
+
}
|
|
9677
|
+
function namespaceConfig(config, tailorDBInputs, namespace) {
|
|
9678
|
+
return tailorDBInputs.find((input) => input.namespace === namespace)?.config ?? config.db?.[namespace];
|
|
9679
|
+
}
|
|
9680
|
+
function namespaceGqlOperations(config, tailorDBInputs, namespace) {
|
|
9681
|
+
return namespaceConfig(config, tailorDBInputs, namespace)?.gqlOperations;
|
|
9682
|
+
}
|
|
9683
|
+
const GQL_OPERATION_KEYS = [
|
|
9684
|
+
"create",
|
|
9685
|
+
"update",
|
|
9686
|
+
"delete",
|
|
9687
|
+
"read"
|
|
9688
|
+
];
|
|
9689
|
+
function configuredDisabledGqlOperations(operations) {
|
|
9690
|
+
if (!operations) return void 0;
|
|
9691
|
+
if (operations === "query") return {
|
|
9692
|
+
create: false,
|
|
9693
|
+
update: false,
|
|
9694
|
+
delete: false
|
|
9695
|
+
};
|
|
9696
|
+
const disabled = {};
|
|
9697
|
+
for (const key of GQL_OPERATION_KEYS) if (operations[key] === false) disabled[key] = false;
|
|
9698
|
+
return definedWhenNotEmpty(disabled);
|
|
9699
|
+
}
|
|
9700
|
+
function appliedConfiguredDisabledGqlOperations(remoteDisabled, configuredDisabled) {
|
|
9701
|
+
if (!remoteDisabled || !configuredDisabled) return void 0;
|
|
9702
|
+
const disabled = {};
|
|
9703
|
+
for (const key of GQL_OPERATION_KEYS) if (configuredDisabled[key] === false && remoteDisabled[key]) disabled[key] = false;
|
|
9704
|
+
return definedWhenNotEmpty(disabled);
|
|
9705
|
+
}
|
|
9706
|
+
function deployComparableSnapshot(snapshot, remoteTypes, gqlOperations) {
|
|
9707
|
+
const remoteTypesByName = new Map(remoteTypes.map((type) => [type.name, type]));
|
|
9708
|
+
const configuredDisabled = configuredDisabledGqlOperations(gqlOperations);
|
|
9709
|
+
const types = {};
|
|
9710
|
+
for (const [typeName, type] of Object.entries(snapshot.types)) {
|
|
9711
|
+
const settings = { ...type.settings };
|
|
9712
|
+
const remoteSettings = remoteTypesByName.get(typeName)?.schema?.settings;
|
|
9713
|
+
if (type.settings?.publishEvents === void 0 && remoteSettings?.publishRecordEvents) settings.publishEvents = true;
|
|
9714
|
+
if (type.settings?.gqlOperations === void 0) {
|
|
9715
|
+
const disabled = appliedConfiguredDisabledGqlOperations(remoteSettings?.disableGqlOperations, configuredDisabled);
|
|
9716
|
+
if (disabled) settings.gqlOperations = disabled;
|
|
9717
|
+
}
|
|
9718
|
+
const comparableType = { ...type };
|
|
9719
|
+
const comparableSettings = definedWhenNotEmpty(settings);
|
|
9720
|
+
if (comparableSettings) comparableType.settings = comparableSettings;
|
|
9721
|
+
else delete comparableType.settings;
|
|
9722
|
+
types[typeName] = comparableType;
|
|
9723
|
+
}
|
|
9724
|
+
return {
|
|
9725
|
+
...snapshot,
|
|
9726
|
+
types
|
|
9727
|
+
};
|
|
9728
|
+
}
|
|
9232
9729
|
/**
|
|
9233
9730
|
* Get the current migration number from remote metadata
|
|
9234
9731
|
* @param {OperatorClient} client - Operator client instance
|
|
@@ -9253,9 +9750,11 @@ async function getRemoteMigrationNumber(client, workspaceId, namespace) {
|
|
|
9253
9750
|
* @param {OperatorClient} client - Operator client instance
|
|
9254
9751
|
* @param {string} workspaceId - Workspace ID
|
|
9255
9752
|
* @param {NamespaceWithMigrations[]} namespacesWithMigrations - Namespaces with migration config
|
|
9753
|
+
* @param {LoadedConfig} config - Loaded application config
|
|
9754
|
+
* @param {ReadonlyArray<TailorDBDeployInput>} tailorDBInputs - Deploy inputs for namespace defaults
|
|
9256
9755
|
* @returns {Promise<RemoteSchemaVerificationResult[]>} Verification results per namespace
|
|
9257
9756
|
*/
|
|
9258
|
-
async function verifyRemoteSchema(client, workspaceId, namespacesWithMigrations) {
|
|
9757
|
+
async function verifyRemoteSchema(client, workspaceId, namespacesWithMigrations, config, tailorDBInputs) {
|
|
9259
9758
|
const results = [];
|
|
9260
9759
|
for (const { namespace, migrationsDir } of namespacesWithMigrations) {
|
|
9261
9760
|
const remoteMigrationNumber = await getRemoteMigrationNumber(client, workspaceId, namespace);
|
|
@@ -9278,7 +9777,8 @@ async function verifyRemoteSchema(client, workspaceId, namespacesWithMigrations)
|
|
|
9278
9777
|
});
|
|
9279
9778
|
continue;
|
|
9280
9779
|
}
|
|
9281
|
-
const
|
|
9780
|
+
const [remoteTypes, remoteGqlPermissions] = await Promise.all([fetchRemoteTypes(client, workspaceId, namespace), fetchRemoteGqlPermissions(client, workspaceId, namespace)]);
|
|
9781
|
+
const drifts = compareRemoteWithSnapshot(remoteTypes, deployComparableSnapshot(expectedSnapshot, remoteTypes, namespaceGqlOperations(config, tailorDBInputs, namespace)), remoteGqlPermissions);
|
|
9282
9782
|
results.push({
|
|
9283
9783
|
namespace,
|
|
9284
9784
|
remoteMigrationNumber,
|
|
@@ -9312,9 +9812,10 @@ function formatRemoteVerificationResults(results) {
|
|
|
9312
9812
|
* @param {ReadonlyMap<string, Record<string, TailorDBSnapshotType>>} typesByNamespace - Types by namespace
|
|
9313
9813
|
* @param {LoadedConfig} config - Loaded application config (includes path)
|
|
9314
9814
|
* @param {boolean} noSchemaCheck - Whether to skip schema diff check
|
|
9815
|
+
* @param {ReadonlyArray<TailorDBDeployInput>} tailorDBInputs - Deploy inputs for namespace defaults
|
|
9315
9816
|
* @returns {Promise<ValidateAndDetectResult>} Pending migrations and namespaces that have migration directories configured
|
|
9316
9817
|
*/
|
|
9317
|
-
async function validateAndDetectMigrations(client, workspaceId, typesByNamespace, config, noSchemaCheck) {
|
|
9818
|
+
async function validateAndDetectMigrations(client, workspaceId, typesByNamespace, config, noSchemaCheck, tailorDBInputs) {
|
|
9318
9819
|
const namespacesWithMigrations = getNamespacesWithMigrations(config, path.dirname(config.path));
|
|
9319
9820
|
let pendingMigrations = [];
|
|
9320
9821
|
if (namespacesWithMigrations.length > 0) {
|
|
@@ -9329,7 +9830,7 @@ async function validateAndDetectMigrations(client, workspaceId, typesByNamespace
|
|
|
9329
9830
|
logger.info("Or use '--no-schema-check' to skip this check.");
|
|
9330
9831
|
throw new Error("Schema migration check failed");
|
|
9331
9832
|
}
|
|
9332
|
-
const remoteVerificationResults = await verifyRemoteSchema(client, workspaceId, namespacesWithMigrations);
|
|
9833
|
+
const remoteVerificationResults = await verifyRemoteSchema(client, workspaceId, namespacesWithMigrations, config, tailorDBInputs);
|
|
9333
9834
|
if (remoteVerificationResults.some((r) => r.hasDrift)) {
|
|
9334
9835
|
logger.error("Remote schema drift detected:");
|
|
9335
9836
|
logger.log(formatRemoteVerificationResults(remoteVerificationResults));
|
|
@@ -9339,6 +9840,12 @@ async function validateAndDetectMigrations(client, workspaceId, typesByNamespace
|
|
|
9339
9840
|
logger.info(" - Manual schema changes were made directly", { mode: "plain" });
|
|
9340
9841
|
logger.info(" - Migration history is out of sync", { mode: "plain" });
|
|
9341
9842
|
logger.newline();
|
|
9843
|
+
logger.info("To resolve:");
|
|
9844
|
+
logger.info(" - Run 'tailor-sdk tailordb migration status' to compare local vs remote.", { mode: "plain" });
|
|
9845
|
+
logger.info(" - If remote is correct, update local types and run 'migration generate'.", { mode: "plain" });
|
|
9846
|
+
logger.info(" - If local migration history is correct, run 'migration sync <N>' to overwrite remote.", { mode: "plain" });
|
|
9847
|
+
logger.info(" - If only bookkeeping is stale, run 'migration set <N>'.", { mode: "plain" });
|
|
9848
|
+
logger.newline();
|
|
9342
9849
|
logger.info("Use '--no-schema-check' to skip this check (not recommended).");
|
|
9343
9850
|
throw new Error("Remote schema verification failed");
|
|
9344
9851
|
}
|
|
@@ -9413,7 +9920,7 @@ async function applyTailorDB(client, result, phase = "create-update") {
|
|
|
9413
9920
|
if (phase === "create-update") {
|
|
9414
9921
|
const typesByNamespace = /* @__PURE__ */ new Map();
|
|
9415
9922
|
for (const tailordb of migrationContext.tailorDBInputs) typesByNamespace.set(tailordb.namespace, tailordb.types);
|
|
9416
|
-
const { pendingMigrations, namespacesWithMigrations } = await validateAndDetectMigrations(client, migrationContext.workspaceId, typesByNamespace, migrationContext.config, migrationContext.noSchemaCheck);
|
|
9923
|
+
const { pendingMigrations, namespacesWithMigrations } = await validateAndDetectMigrations(client, migrationContext.workspaceId, typesByNamespace, migrationContext.config, migrationContext.noSchemaCheck, migrationContext.tailorDBInputs);
|
|
9417
9924
|
if (pendingMigrations.length > 0) {
|
|
9418
9925
|
processedTypes.reset();
|
|
9419
9926
|
deletedResources.reset();
|
|
@@ -9877,29 +10384,19 @@ async function planServices(client, workspaceId, appName, appId, tailordbs) {
|
|
|
9877
10384
|
const conflicts = [];
|
|
9878
10385
|
const unmanaged = [];
|
|
9879
10386
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
9880
|
-
const
|
|
9881
|
-
|
|
10387
|
+
const existingServices = await fetchExistingResourcesWithLabels({
|
|
10388
|
+
client,
|
|
10389
|
+
fetchPage: async (pageToken, maxPageSize) => {
|
|
9882
10390
|
const { tailordbServices, nextPageToken } = await client.listTailorDBServices({
|
|
9883
10391
|
workspaceId,
|
|
9884
10392
|
pageToken,
|
|
9885
10393
|
pageSize: maxPageSize
|
|
9886
10394
|
});
|
|
9887
10395
|
return [tailordbServices, nextPageToken];
|
|
9888
|
-
}
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
}
|
|
10396
|
+
},
|
|
10397
|
+
getName: (resource) => resource.namespace?.name,
|
|
10398
|
+
getTrn: (name) => resourceTrn(workspaceId, "tailordb", name)
|
|
9892
10399
|
});
|
|
9893
|
-
const existingServices = {};
|
|
9894
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
9895
|
-
if (!resource.namespace?.name) return;
|
|
9896
|
-
const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "tailordb", resource.namespace.name) });
|
|
9897
|
-
existingServices[resource.namespace.name] = {
|
|
9898
|
-
resource,
|
|
9899
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
9900
|
-
allLabels: metadata?.labels
|
|
9901
|
-
};
|
|
9902
|
-
}));
|
|
9903
10400
|
for (const tailordb of tailordbs) {
|
|
9904
10401
|
const existing = existingServices[tailordb.namespace];
|
|
9905
10402
|
const metaRequest = await buildMetaRequest({
|
|
@@ -10328,7 +10825,7 @@ function filterJobFunctionVersions(allVersions, usedJobNames) {
|
|
|
10328
10825
|
* @param client - Operator client instance
|
|
10329
10826
|
* @param changeSet - Workflow change set
|
|
10330
10827
|
* @param appName - Application name
|
|
10331
|
-
* @param appId
|
|
10828
|
+
* @param appId - Application ID used for job function metadata when available
|
|
10332
10829
|
* @param unchangedWorkflowJobNames - Job function names used by unchanged workflows
|
|
10333
10830
|
* @returns Map of job function names to versions
|
|
10334
10831
|
*/
|
|
@@ -10414,7 +10911,7 @@ function buildWorkflowValidationShape(workspaceId, workflow) {
|
|
|
10414
10911
|
* @param client - Operator client instance
|
|
10415
10912
|
* @param workspaceId - Workspace ID
|
|
10416
10913
|
* @param appName - Application name
|
|
10417
|
-
* @param appId
|
|
10914
|
+
* @param appId - Application ID used for workflow metadata when available
|
|
10418
10915
|
* @param workflows - Parsed workflows
|
|
10419
10916
|
* @param mainJobDeps - Main job dependencies by workflow
|
|
10420
10917
|
* @param unchangedJobFunctions - Job functions already proven unchanged by function registry plan
|
|
@@ -10429,7 +10926,6 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
10429
10926
|
const retainedWorkflowJobNames = /* @__PURE__ */ new Set();
|
|
10430
10927
|
const existingWorkflows = await fetchExistingResourcesWithLabels({
|
|
10431
10928
|
client,
|
|
10432
|
-
workspaceId,
|
|
10433
10929
|
fetchPage: async (pageToken, pageSize) => {
|
|
10434
10930
|
const response = await client.listWorkflows({
|
|
10435
10931
|
workspaceId,
|
|
@@ -10439,7 +10935,7 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
10439
10935
|
return [response.workflows, response.nextPageToken];
|
|
10440
10936
|
},
|
|
10441
10937
|
getName: (resource) => resource.name,
|
|
10442
|
-
getTrn: (
|
|
10938
|
+
getTrn: (name) => resourceTrn(workspaceId, "workflow", name)
|
|
10443
10939
|
});
|
|
10444
10940
|
for (const workflow of Object.values(workflows)) {
|
|
10445
10941
|
const existing = existingWorkflows[workflow.name];
|
|
@@ -16209,7 +16705,7 @@ async function generate(options) {
|
|
|
16209
16705
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
16210
16706
|
let pluginManager;
|
|
16211
16707
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
16212
|
-
const { defineApplication } = await import("./application-
|
|
16708
|
+
const { defineApplication } = await import("./application-BXdCl6bp.mjs");
|
|
16213
16709
|
const application = defineApplication({
|
|
16214
16710
|
config,
|
|
16215
16711
|
pluginManager
|
|
@@ -18139,7 +18635,7 @@ async function runRepl(options) {
|
|
|
18139
18635
|
const execute = await prepareQueryExecutor(options);
|
|
18140
18636
|
const historyPath = getReplHistoryPath(options.engine, options.profile, options.workspaceId);
|
|
18141
18637
|
const validate = createReplValidator(options.engine);
|
|
18142
|
-
const { highlightSqlLine, highlightGraphqlLine, replTransform } = await import("./repl-editor-
|
|
18638
|
+
const { highlightSqlLine, highlightGraphqlLine, replTransform } = await import("./repl-editor-BmQOyZJd.mjs");
|
|
18143
18639
|
const highlight = options.engine === "sql" ? highlightSqlLine : highlightGraphqlLine;
|
|
18144
18640
|
const prompt = createPrompt({
|
|
18145
18641
|
prefix: "",
|
|
@@ -18474,4 +18970,4 @@ function isDeno() {
|
|
|
18474
18970
|
|
|
18475
18971
|
//#endregion
|
|
18476
18972
|
export { getOrganization as $, generateAllTypeManifestsFromSnapshot as $t, listCommand$3 as A, apiCommand as An, getExecutorWaitFailureMessage as At, show as B, paginationArgs as Bn, listWorkflowExecutions as Bt, listCommand$2 as C, getNamespacesWithMigrations as Cn, listWebhookExecutors as Ct, waitWorkflowExecution as D, PluginManager as Dn, listCommand$9 as Dt, waitCommand as E, sdkNameLabelKey as En, triggerExecutor as Et, generateCommand as F, configArg as Fn, startWorkflow as Ft, removeCommand$1 as G, deploy as Gt, extractOwnedNamespaces as H, workspaceArgs as Hn, formatKeyValueTable as Ht, generateMigrationScript as I, confirmationArgs as In, getCommand$5 as It, organizationTree as J, bundleMigrationScript as Jt, updateCommand$1 as K, executeScript as Kt, writeDbTypesFile as L, deploymentArgs as Ln, getWorkflow as Lt, truncate as M, assertWritable as Mn, listExecutorJobs as Mt, truncateCommand as N, defineAppCommand as Nn, watchExecutorJob as Nt, resumeCommand as O, generateUserTypes as On, listExecutors as Ot, generate as P, commonArgs as Pn, startCommand as Pt, getCommand$1 as Q, compareSnapshotWithRemote as Qt, getConfiguredEditorCommand as R, isVerbose as Rn, executionsCommand as Rt, listApps as S, hasChanges as Sn, getFunctionRegistry as St, healthCommand as T, resourceTrn as Tn, triggerCommand as Tt, logBetaWarning as U, getCommand$6 as Ut, showCommand as V, toPageDirection as Vn, functionExecutionStatusToString as Vt, remove as W, getExecutor as Wt, listCommand$4 as X, handleOptionalToRequiredError as Xt, treeCommand as Y, MIGRATION_LABEL_KEY as Yt, listOrganizations as Z, parseMigrationLabelNumber as Zt, getWorkspace as _, reconstructSnapshotFromMigrations as _n, listMachineUsers as _t, updateUser as a, SCHEMA_FILE_NAME as an, getFolder as at, createCommand as b, formatDiffSummary as bn, listFunctionRegistries as bt, listCommand as c, compareSnapshots as cn, createCommand$1 as ct, inviteUser as d, getMigrationDirPath as dn, listOAuth2Clients as dt, protoGqlPermission as en, updateCommand$2 as et, restoreCommand as f, getMigrationFilePath as fn, getCommand$3 as ft, getCommand as g, loadDiff as gn, listCommand$7 as gt, listWorkspaces as h, isValidMigrationNumber as hn, tokenCommand as ht, updateCommand as i, MIGRATE_FILE_NAME as in, getCommand$2 as it, listWorkflows as j, apiCall as jn, jobsCommand as jt, resumeWorkflow as k, prompt as kn, getExecutorJob as kt, listUsers as l, createSnapshotFromLocalTypes as ln, createFolder as lt, listCommand$1 as m, getNextMigrationNumber as mn, getMachineUserToken as mt, query as n, DIFF_FILE_NAME as nn, listCommand$5 as nt, removeCommand as o, assertValidMigrationFiles as on, deleteCommand$1 as ot, restoreWorkspace as p, getMigrationFiles as pn, getOAuth2Client as pt, updateOrganization as q, waitForExecution as qt, queryCommand as r, INITIAL_SCHEMA_NUMBER as rn, listFolders as rt, removeUser as s, compareLocalTypesWithSnapshot as sn, deleteFolder as st, isNativeTypeScriptRuntime as t, DB_TYPES_FILE_NAME as tn, updateFolder as tt, inviteCommand as u, getLatestMigrationNumber as un, listCommand$6 as ut, deleteCommand as v, formatMigrationNumber as vn, generate$1 as vt, getAppHealth as w, ensureConfigId as wn, webhookCommand as wt, createWorkspace as x, formatMigrationDiff as xn, getCommand$4 as xt, deleteWorkspace as y, parseMigrationNumberArg as yn, listCommand$8 as yt, openInConfiguredEditor as z, pagedLogArgs as zn, getWorkflowExecution as zt };
|
|
18477
|
-
//# sourceMappingURL=runtime-
|
|
18973
|
+
//# sourceMappingURL=runtime-B8O6JFS2.mjs.map
|