@health-samurai/react-components 0.0.0-alpha.18 → 0.0.0-alpha.20

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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bundle.css +51 -33
  3. package/dist/src/components/code-editor/fhir-autocomplete.d.ts +70 -0
  4. package/dist/src/components/code-editor/fhir-autocomplete.d.ts.map +1 -0
  5. package/dist/src/components/code-editor/fhir-autocomplete.js +1849 -0
  6. package/dist/src/components/code-editor/fhir-autocomplete.js.map +1 -0
  7. package/dist/src/components/code-editor/fhir-autocomplete.test.js +1099 -0
  8. package/dist/src/components/code-editor/fhir-autocomplete.test.js.map +1 -0
  9. package/dist/src/components/code-editor/http/index.d.ts +9 -1
  10. package/dist/src/components/code-editor/http/index.d.ts.map +1 -1
  11. package/dist/src/components/code-editor/http/index.js +423 -3
  12. package/dist/src/components/code-editor/http/index.js.map +1 -1
  13. package/dist/src/components/code-editor/index.d.ts +13 -4
  14. package/dist/src/components/code-editor/index.d.ts.map +1 -1
  15. package/dist/src/components/code-editor/index.js +505 -96
  16. package/dist/src/components/code-editor/index.js.map +1 -1
  17. package/dist/src/components/code-editor/json-ast.d.ts +46 -0
  18. package/dist/src/components/code-editor/json-ast.d.ts.map +1 -0
  19. package/dist/src/components/code-editor/json-ast.js +465 -0
  20. package/dist/src/components/code-editor/json-ast.js.map +1 -0
  21. package/dist/src/components/code-editor/json-ast.test.js +206 -0
  22. package/dist/src/components/code-editor/json-ast.test.js.map +1 -0
  23. package/dist/src/components/code-editor/sql-completion.d.ts +22 -0
  24. package/dist/src/components/code-editor/sql-completion.d.ts.map +1 -0
  25. package/dist/src/components/code-editor/sql-completion.js +895 -0
  26. package/dist/src/components/code-editor/sql-completion.js.map +1 -0
  27. package/dist/src/components/date-picker-input.d.ts +10 -0
  28. package/dist/src/components/date-picker-input.d.ts.map +1 -0
  29. package/dist/src/components/date-picker-input.js +90 -0
  30. package/dist/src/components/date-picker-input.js.map +1 -0
  31. package/dist/src/components/date-picker-input.stories.js +76 -0
  32. package/dist/src/components/date-picker-input.stories.js.map +1 -0
  33. package/dist/src/index.d.ts +1 -0
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/index.js +1 -0
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/src/shadcn/components/ui/alert-dialog.d.ts +1 -1
  38. package/dist/src/shadcn/components/ui/calendar.d.ts +1 -1
  39. package/dist/src/shadcn/components/ui/carousel.d.ts +1 -1
  40. package/dist/src/shadcn/components/ui/chart.d.ts +3 -3
  41. package/dist/src/shadcn/components/ui/chart.d.ts.map +1 -1
  42. package/dist/src/shadcn/components/ui/chart.js +1 -1
  43. package/dist/src/shadcn/components/ui/chart.js.map +1 -1
  44. package/dist/src/shadcn/components/ui/command.d.ts +1 -1
  45. package/dist/src/shadcn/components/ui/pagination.d.ts +1 -1
  46. package/dist/src/shadcn/components/ui/resizable.stories.js +2 -2
  47. package/dist/src/shadcn/components/ui/resizable.stories.js.map +1 -1
  48. package/dist/src/shadcn/components/ui/sidebar.d.ts +4 -4
  49. package/dist/src/shadcn/components/ui/tabs.d.ts +3 -1
  50. package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
  51. package/dist/src/shadcn/components/ui/tabs.js +129 -2
  52. package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
  53. package/dist/src/shadcn/components/ui/tabs.stories.js +1 -1
  54. package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
  55. package/dist/src/shadcn/components/ui/toggle-group.d.ts +1 -1
  56. package/dist/src/typography.css +1 -1
  57. package/package.json +24 -19
  58. package/src/components/code-editor/fhir-autocomplete.test.ts +993 -0
  59. package/src/components/code-editor/fhir-autocomplete.ts +2321 -0
  60. package/src/components/code-editor/http/index.ts +339 -2
  61. package/src/components/code-editor/index.tsx +593 -102
  62. package/src/components/code-editor/json-ast.test.ts +230 -0
  63. package/src/components/code-editor/json-ast.ts +590 -0
  64. package/src/components/code-editor/sql-completion.ts +1105 -0
  65. package/src/components/date-picker-input.stories.tsx +79 -0
  66. package/src/components/date-picker-input.tsx +104 -0
  67. package/src/index.tsx +1 -0
  68. package/src/shadcn/components/ui/chart.tsx +6 -3
  69. package/src/shadcn/components/ui/resizable.stories.tsx +2 -2
  70. package/src/shadcn/components/ui/tabs.stories.tsx +1 -1
  71. package/src/shadcn/components/ui/tabs.tsx +160 -2
  72. package/src/typography.css +1 -1
  73. package/dist/src/components/code-editor/http/grammar/http.test.d.ts +0 -2
  74. package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/code-editor/fhir-autocomplete.test.ts"],"sourcesContent":["import { CompletionContext } from \"@codemirror/autocomplete\";\nimport { json } from \"@codemirror/lang-json\";\nimport { EditorState } from \"@codemirror/state\";\nimport { describe, expect, it } from \"vitest\";\nimport {\n\tbuildParameterSnippet,\n\ttype ExpandValueSet,\n\ttype GetStructureDefinitions,\n\tjsonCompletionSource,\n} from \"./fhir-autocomplete\";\n\n// ── Minimal mock SDs ───────────────────────────────────────────────────\n\nconst PATIENT_SD = {\n\ttype: \"Patient\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Patient\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/DomainResource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Patient\", min: 0, max: \"*\" },\n\t\t\t{ path: \"Patient.name\", min: 0, max: \"*\", type: [{ code: \"HumanName\" }] },\n\t\t\t{\n\t\t\t\tpath: \"Patient.gender\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"code\" }],\n\t\t\t\tbinding: {\n\t\t\t\t\tvalueSet: \"http://hl7.org/fhir/ValueSet/administrative-gender\",\n\t\t\t\t\tstrength: \"required\",\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ path: \"Patient.birthDate\", min: 0, max: \"1\", type: [{ code: \"date\" }] },\n\t\t\t{ path: \"Patient.active\", min: 0, max: \"1\", type: [{ code: \"boolean\" }] },\n\t\t\t{\n\t\t\t\tpath: \"Patient.managingOrganization\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"Reference\",\n\t\t\t\t\t\ttargetProfile: [\n\t\t\t\t\t\t\t\"http://hl7.org/fhir/StructureDefinition/Organization\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Patient.contained\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"Resource\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Patient.meta\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"Meta\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst OBSERVATION_SD = {\n\ttype: \"Observation\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Observation\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/DomainResource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Observation\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"Observation.status\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"code\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Observation.code\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"CodeableConcept\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Observation.subject\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"Reference\",\n\t\t\t\t\t\ttargetProfile: [\n\t\t\t\t\t\t\t\"http://hl7.org/fhir/StructureDefinition/Patient\",\n\t\t\t\t\t\t\t\"http://hl7.org/fhir/StructureDefinition/Group\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst DOMAIN_RESOURCE_SD = {\n\ttype: \"DomainResource\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/DomainResource\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Resource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"DomainResource\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"DomainResource.text\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"Narrative\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"DomainResource.contained\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"Resource\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"DomainResource.extension\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"Extension\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"DomainResource.modifierExtension\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"Extension\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst RESOURCE_SD = {\n\ttype: \"Resource\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Resource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Resource\", min: 0, max: \"*\" },\n\t\t\t{ path: \"Resource.id\", min: 0, max: \"1\", type: [{ code: \"id\" }] },\n\t\t\t{ path: \"Resource.meta\", min: 0, max: \"1\", type: [{ code: \"Meta\" }] },\n\t\t],\n\t},\n};\n\nconst HUMAN_NAME_SD = {\n\ttype: \"HumanName\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/HumanName\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"HumanName\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"HumanName.family\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t\t{ path: \"HumanName.given\", min: 0, max: \"*\", type: [{ code: \"string\" }] },\n\t\t],\n\t},\n};\n\nconst REFERENCE_SD = {\n\ttype: \"Reference\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Reference\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Reference\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"Reference.reference\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Reference.display\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst META_SD = {\n\ttype: \"Meta\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Meta\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Meta\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"Meta.profile\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"canonical\",\n\t\t\t\t\t\ttargetProfile: [\n\t\t\t\t\t\t\t\"http://hl7.org/fhir/StructureDefinition/StructureDefinition\",\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst BUNDLE_SD = {\n\ttype: \"Bundle\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Bundle\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Resource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Bundle\", min: 0, max: \"*\" },\n\t\t\t{ path: \"Bundle.type\", min: 1, max: \"1\", type: [{ code: \"code\" }] },\n\t\t\t{\n\t\t\t\tpath: \"Bundle.entry\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"BackboneElement\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Bundle.entry.resource\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"Resource\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst PARAMETERS_SD = {\n\ttype: \"Parameters\",\n\turl: \"http://hl7.org/fhir/StructureDefinition/Parameters\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Resource\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Parameters\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\ttype: [{ code: \"BackboneElement\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.name\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.value[x]\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [\n\t\t\t\t\t{ code: \"string\" },\n\t\t\t\t\t{ code: \"boolean\" },\n\t\t\t\t\t{ code: \"integer\" },\n\t\t\t\t\t{ code: \"code\" },\n\t\t\t\t\t{ code: \"Reference\" },\n\t\t\t\t\t{ code: \"CodeableConcept\" },\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.resource\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"Resource\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.part\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"*\",\n\t\t\t\tcontentReference: \"#Parameters.parameter\",\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst INSTALL_PARAMS_PROFILE = {\n\ttype: \"Parameters\",\n\turl: \"http://health-samurai.io/fhir/core/StructureDefinition/fhir-package-install-parameters\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Parameters\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"Parameters.parameter\", min: 1 },\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter\",\n\t\t\t\tsliceName: \"package\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"*\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.name\",\n\t\t\t\tfixedString: \"package\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter\",\n\t\t\t\tsliceName: \"registry\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.name\",\n\t\t\t\tfixedString: \"registry\",\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst TYPED_PARAMS_PROFILE = {\n\ttype: \"Parameters\",\n\turl: \"http://example.com/StructureDefinition/typed-params\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Parameters\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter\",\n\t\t\t\tsliceName: \"count\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.name\",\n\t\t\t\tfixedString: \"count\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.value[x]\",\n\t\t\t\ttype: [{ code: \"integer\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter\",\n\t\t\t\tsliceName: \"label\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.name\",\n\t\t\t\tfixedString: \"label\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"Parameters.parameter.value[x]\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst TOPIC_DEST_SD = {\n\ttype: \"AidboxTopicDestination\",\n\turl: \"http://aidbox.app/StructureDefinition/AidboxTopicDestination\",\n\tbaseDefinition: \"http://hl7.org/fhir/StructureDefinition/Parameters\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{ path: \"AidboxTopicDestination\", min: 0, max: \"*\" },\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.kind\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst TOPIC_DEST_KAFKA_PROFILE = {\n\ttype: \"AidboxTopicDestination\",\n\turl: \"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\",\n\tbaseDefinition:\n\t\t\"http://aidbox.app/StructureDefinition/AidboxTopicDestination\",\n\tdifferential: {\n\t\telement: [\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.kind\",\n\t\t\t\tfixedString: \"kafka-best-effort\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter\",\n\t\t\t\tsliceName: \"kafkaTopic\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.name\",\n\t\t\t\tfixedString: \"kafkaTopic\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.value[x]\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter\",\n\t\t\t\tsliceName: \"bootstrapServers\",\n\t\t\t\tmin: 1,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.name\",\n\t\t\t\tfixedString: \"bootstrapServers\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.value[x]\",\n\t\t\t\ttype: [{ code: \"string\" }],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter\",\n\t\t\t\tsliceName: \"batchSize\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: \"1\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.name\",\n\t\t\t\tfixedString: \"batchSize\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"AidboxTopicDestination.parameter.value[x]\",\n\t\t\t\ttype: [{ code: \"integer\" }],\n\t\t\t},\n\t\t],\n\t},\n};\n\nconst RESOURCE_TYPE_LIST = [\n\t{ type: \"Patient\" },\n\t{ type: \"Observation\" },\n\t{ type: \"Organization\" },\n\t{ type: \"Bundle\" },\n\t{ type: \"Parameters\" },\n\t{ type: \"AidboxTopicDestination\" },\n];\n\nconst ALL_SDS: Record<string, typeof PATIENT_SD> = {\n\tPatient: PATIENT_SD,\n\tObservation: OBSERVATION_SD,\n\tDomainResource: DOMAIN_RESOURCE_SD,\n\tResource: RESOURCE_SD,\n\tHumanName: HUMAN_NAME_SD,\n\tReference: REFERENCE_SD,\n\tMeta: META_SD,\n\tBundle: BUNDLE_SD,\n\tParameters: PARAMETERS_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Patient\": PATIENT_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Observation\": OBSERVATION_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/DomainResource\": DOMAIN_RESOURCE_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Resource\": RESOURCE_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/HumanName\": HUMAN_NAME_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Reference\": REFERENCE_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Meta\": META_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Bundle\": BUNDLE_SD,\n\t\"http://hl7.org/fhir/StructureDefinition/Parameters\": PARAMETERS_SD,\n\t\"http://health-samurai.io/fhir/core/StructureDefinition/fhir-package-install-parameters\":\n\t\tINSTALL_PARAMS_PROFILE,\n\t\"http://example.com/StructureDefinition/typed-params\": TYPED_PARAMS_PROFILE,\n\tAidboxTopicDestination: TOPIC_DEST_SD,\n\t\"http://aidbox.app/StructureDefinition/AidboxTopicDestination\": TOPIC_DEST_SD,\n\t\"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\":\n\t\tTOPIC_DEST_KAFKA_PROFILE,\n};\n\n// ── Mock getSDs ────────────────────────────────────────────────────────\n\nconst mockGetSDs: GetStructureDefinitions = async (params) => {\n\tif (params.kind === \"resource\" && params.derivation === \"specialization\") {\n\t\treturn RESOURCE_TYPE_LIST as (typeof PATIENT_SD)[];\n\t}\n\tif (params.url) {\n\t\tconst sd = ALL_SDS[params.url];\n\t\treturn sd ? [sd] : [];\n\t}\n\tif (params.type && params.derivation === \"specialization\") {\n\t\tconst sd = ALL_SDS[params.type];\n\t\treturn sd ? [sd] : [];\n\t}\n\tif (params.type && params[\"derivation:missing\"] === \"true\") {\n\t\tconst sd = ALL_SDS[params.type];\n\t\treturn sd ? [sd] : [];\n\t}\n\tif (params.type === \"Extension\") {\n\t\treturn [];\n\t}\n\treturn [];\n};\n\nconst mockExpandValueSet: ExpandValueSet = async (url, _filter) => {\n\tif (url === \"http://hl7.org/fhir/ValueSet/administrative-gender\") {\n\t\treturn [\n\t\t\t{ code: \"male\", display: \"Male\" },\n\t\t\t{ code: \"female\", display: \"Female\" },\n\t\t\t{ code: \"other\", display: \"Other\" },\n\t\t\t{ code: \"unknown\", display: \"Unknown\" },\n\t\t];\n\t}\n\treturn [];\n};\n\n// ── Test helpers ───────────────────────────────────────────────────────\n\nfunction completionAt(doc: string, marker = \"|\") {\n\tconst pos = doc.indexOf(marker);\n\tconst text = doc.slice(0, pos) + doc.slice(pos + 1);\n\tconst state = EditorState.create({ doc: text, extensions: [json()] });\n\tconst cc = new CompletionContext(state, pos, true);\n\treturn { state, cc, pos };\n}\n\nfunction labels(result: { options: { label: string }[] } | null): string[] {\n\treturn result?.options.map((o) => o.label) ?? [];\n}\n\n// ── Caches persist across tests — clear between describes ──────────────\n\n// The SD cache is module-level in fhir-autocomplete.ts.\n// Since we use consistent mock data, the cache doesn't cause issues.\n\n// ── Tests ──────────────────────────────────────────────────────────────\n\ndescribe(\"fhir-autocomplete: jsonCompletionSource\", () => {\n\tconst source = jsonCompletionSource(\n\t\tmockGetSDs,\n\t\tundefined,\n\t\tmockExpandValueSet,\n\t);\n\n\tdescribe(\"resourceType value completions\", () => {\n\t\tit(\"offers resource types in empty resourceType value\", async () => {\n\t\t\tconst { cc } = completionAt('{\\n \"resourceType\": \"|\\n}');\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"Patient\");\n\t\t\texpect(l).toContain(\"Observation\");\n\t\t\texpect(l).toContain(\"Organization\");\n\t\t});\n\t});\n\n\tdescribe(\"property completions\", () => {\n\t\tit(\"offers Patient fields when resourceType is set\", async () => {\n\t\t\tconst { cc } = completionAt('{\\n \"resourceType\": \"Patient\",\\n |\\n}');\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"gender\");\n\t\t\texpect(l).toContain(\"birthDate\");\n\t\t\texpect(l).toContain(\"managingOrganization\");\n\t\t});\n\n\t\tit(\"offers resourceType when no resourceType is set\", async () => {\n\t\t\tconst { cc } = completionAt(\"{\\n |\\n}\");\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"resourceType\");\n\t\t});\n\n\t\tit(\"offers primitive extensions (_birthDate)\", async () => {\n\t\t\tconst { cc } = completionAt('{\\n \"resourceType\": \"Patient\",\\n |\\n}');\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"_birthDate\");\n\t\t\texpect(l).toContain(\"_gender\");\n\t\t});\n\n\t\tit(\"excludes properties already present in object\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"gender\": \"male\",\\n |\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"birthDate\");\n\t\t\texpect(l).not.toContain(\"gender\");\n\t\t\texpect(l).not.toContain(\"resourceType\");\n\t\t});\n\n\t\tit(\"does not offer property completions inside arrays\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"name\": [\\n |\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\texpect(result).toBe(null);\n\t\t});\n\t});\n\n\tdescribe(\"property completions with resourceTypeHint\", () => {\n\t\tconst hintSource = jsonCompletionSource(\n\t\t\tmockGetSDs,\n\t\t\t\"Patient\",\n\t\t\tmockExpandValueSet,\n\t\t);\n\n\t\tit(\"uses hint when resourceType is not in document\", async () => {\n\t\t\tconst { cc } = completionAt(\"{\\n |\\n}\");\n\t\t\tconst result = await hintSource(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"gender\");\n\t\t});\n\t});\n\n\tdescribe(\"terminology binding completions\", () => {\n\t\tit(\"offers gender codes for Patient.gender\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"gender\": \"|\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"male\");\n\t\t\texpect(l).toContain(\"female\");\n\t\t\texpect(l).toContain(\"other\");\n\t\t\texpect(l).toContain(\"unknown\");\n\t\t});\n\t});\n\n\tdescribe(\"boolean value completions\", () => {\n\t\tit(\"offers true and false for boolean fields\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"active\": |\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"true\");\n\t\t\texpect(l).toContain(\"false\");\n\t\t\texpect(l).toHaveLength(2);\n\t\t});\n\n\t\tit(\"offers property completions (not booleans) on new line after boolean value\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"active\": true,\\n |\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).not.toContain(\"true\");\n\t\t\texpect(l).not.toContain(\"false\");\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"gender\");\n\t\t});\n\t});\n\n\tdescribe(\"reference target completions\", () => {\n\t\tit(\"offers Organization/ for Patient.managingOrganization.reference\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"managingOrganization\": {\\n \"reference\": \"|\\n }\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"Organization/\");\n\t\t});\n\n\t\tit(\"offers Patient/ and Group/ for Observation.subject.reference\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Observation\",\\n \"subject\": {\\n \"reference\": \"|\\n }\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"Patient/\");\n\t\t\texpect(l).toContain(\"Group/\");\n\t\t});\n\t});\n\n\tdescribe(\"contained resource completions\", () => {\n\t\tit(\"offers resourceType inside contained array item\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"contained\": [\\n {\\n |\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"resourceType\");\n\t\t});\n\n\t\tit(\"offers inner resource fields when contained has resourceType\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"contained\": [\\n {\\n \"resourceType\": \"Observation\",\\n |\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"status\");\n\t\t\texpect(l).toContain(\"code\");\n\t\t\texpect(l).toContain(\"subject\");\n\t\t\t// Should NOT contain Patient fields\n\t\t\texpect(l).not.toContain(\"gender\");\n\t\t\texpect(l).not.toContain(\"birthDate\");\n\t\t});\n\n\t\tit(\"offers correct reference targets for contained Observation.subject\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"contained\": [\\n {\\n \"resourceType\": \"Observation\",\\n \"subject\": {\\n \"reference\": \"|\\n }\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"Patient/\");\n\t\t\texpect(l).toContain(\"Group/\");\n\t\t\t// Should NOT contain Organization/ (that's from Patient.managingOrganization)\n\t\t\texpect(l).not.toContain(\"Organization/\");\n\t\t});\n\t});\n\n\tdescribe(\"Bundle.entry.resource completions\", () => {\n\t\tit(\"offers Observation fields inside entry.resource with explicit Bundle resourceType\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Bundle\",\\n \"entry\": [\\n {\\n \"resource\": {\\n \"resourceType\": \"Observation\",\\n |\\n }\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"status\");\n\t\t\texpect(l).toContain(\"code\");\n\t\t\texpect(l).toContain(\"subject\");\n\t\t\texpect(l).not.toContain(\"type\");\n\t\t});\n\n\t\tit(\"offers Observation fields when Bundle resourceType comes from hint (URL)\", async () => {\n\t\t\tconst hintSource = jsonCompletionSource(\n\t\t\t\tmockGetSDs,\n\t\t\t\t\"Bundle\",\n\t\t\t\tmockExpandValueSet,\n\t\t\t);\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"entry\": [\\n {\\n \"resource\": {\\n \"resourceType\": \"Observation\",\\n |\\n }\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await hintSource(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"status\");\n\t\t\texpect(l).toContain(\"code\");\n\t\t\texpect(l).toContain(\"subject\");\n\t\t\texpect(l).not.toContain(\"type\");\n\t\t});\n\t});\n\n\tdescribe(\"nested object completions\", () => {\n\t\tit(\"offers HumanName fields inside name array item\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"name\": [\\n {\\n |\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"family\");\n\t\t\texpect(l).toContain(\"given\");\n\t\t});\n\n\t\tit(\"offers Reference fields inside managingOrganization\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Patient\",\\n \"managingOrganization\": {\\n |\\n }\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"reference\");\n\t\t\texpect(l).toContain(\"display\");\n\t\t});\n\t});\n\n\tdescribe(\"Parameters completions\", () => {\n\t\tit(\"offers parameter fields inside parameter array item object\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"parameter\": [\\n {\\n |\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"valueString\");\n\t\t\texpect(l).toContain(\"valueBoolean\");\n\t\t\texpect(l).toContain(\"resource\");\n\t\t\texpect(l).toContain(\"part\");\n\t\t});\n\n\t\tit(\"offers slice names for parameter.name from profile\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"meta\": {\\n \"profile\": [\"http://health-samurai.io/fhir/core/StructureDefinition/fhir-package-install-parameters\"]\\n },\\n \"parameter\": [\\n {\\n \"name\": \"|\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"package\");\n\t\t\texpect(l).toContain(\"registry\");\n\t\t});\n\n\t\tit(\"offers parameter snippets in array-item position from profile\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"meta\": {\\n \"profile\": [\"http://health-samurai.io/fhir/core/StructureDefinition/fhir-package-install-parameters\"]\\n },\\n \"parameter\": [\\n |\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"package\");\n\t\t\texpect(l).toContain(\"registry\");\n\t\t\texpect(l).toContain(\"parameter\");\n\t\t});\n\n\t\tit(\"offers generic parameter template without profile\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"parameter\": [\\n |\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\texpect(result).not.toBe(null);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"parameter\");\n\t\t});\n\n\t\tit(\"offers parameter fields for second array item\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"parameter\": [\\n {\"name\": \"a\", \"valueString\": \"1\"},\\n {\\n |\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"valueString\");\n\t\t\texpect(l).not.toContain(\"parameter\");\n\t\t});\n\n\t\tit(\"offers slice names for second array item name value\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"AidboxTopicDestination\",\\n \"meta\": {\\n \"profile\": [\"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\"]\\n },\\n \"parameter\": [\\n {\"name\": \"kafkaTopic\", \"valueString\": \"1\"},\\n {\\n \"name\": \"|\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"bootstrapServers\");\n\t\t\texpect(l).toContain(\"batchSize\");\n\t\t});\n\n\t\tit(\"offers part fields via contentReference\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"parameter\": [\\n {\\n \"name\": \"result\",\\n \"part\": [\\n {\\n |\\n }\\n ]\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"valueString\");\n\t\t\texpect(l).toContain(\"part\");\n\t\t});\n\n\t\tit(\"offers typed snippet for profile with value[x] constraint\", async () => {\n\t\t\tconst typedSource = jsonCompletionSource(\n\t\t\t\tmockGetSDs,\n\t\t\t\tundefined,\n\t\t\t\tmockExpandValueSet,\n\t\t\t);\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"meta\": {\\n \"profile\": [\"http://example.com/StructureDefinition/typed-params\"]\\n },\\n \"parameter\": [\\n |\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await typedSource(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"count\");\n\t\t\texpect(l).toContain(\"label\");\n\t\t});\n\n\t\tit(\"works for Parameters-derived types (AidboxTopicDestination)\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"AidboxTopicDestination\",\\n \"meta\": {\\n \"profile\": [\"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\"]\\n },\\n \"parameter\": [\\n |\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"kafkaTopic\");\n\t\t\texpect(l).toContain(\"bootstrapServers\");\n\t\t\texpect(l).toContain(\"batchSize\");\n\t\t});\n\n\t\tit(\"offers slice names for derived type parameter.name\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"AidboxTopicDestination\",\\n \"meta\": {\\n \"profile\": [\"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\"]\\n },\\n \"parameter\": [\\n {\\n \"name\": \"|\\n }\\n ]\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"kafkaTopic\");\n\t\t\texpect(l).toContain(\"bootstrapServers\");\n\t\t\texpect(l).toContain(\"batchSize\");\n\t\t});\n\n\t\tit(\"offers fixed value for profiled field\", async () => {\n\t\t\tconst { cc } = completionAt(\n\t\t\t\t'{\\n \"resourceType\": \"AidboxTopicDestination\",\\n \"meta\": {\\n \"profile\": [\"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-best-effort\"]\\n },\\n \"kind\": \"|\\n}',\n\t\t\t);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"kafka-best-effort\");\n\t\t});\n\n\t\tit(\"generic parameter snippet is offered with lowest boost\", async () => {\n\t\t\tconst doc =\n\t\t\t\t'{\\n \"resourceType\": \"Parameters\",\\n \"parameter\": [\\n |\\n ]\\n}';\n\t\t\tconst { cc } = completionAt(doc);\n\t\t\tconst result = await source(cc);\n\t\t\tconst option = result?.options.find((o) => o.label === \"parameter\");\n\t\t\texpect(option).toBeDefined();\n\t\t\texpect(option?.boost).toBe(-1);\n\t\t\texpect(option?.info).toBe(\"Custom parameter\");\n\t\t});\n\t});\n\n\tdescribe(\"HTTP mode\", () => {\n\t\tit(\"offers Patient fields in HTTP mode body\", async () => {\n\t\t\tconst doc =\n\t\t\t\t'POST /fhir/Patient\\nContent-Type: application/json\\n\\n{\\n \"resourceType\": \"Patient\",\\n |\\n}';\n\t\t\tconst { cc } = completionAt(doc);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"name\");\n\t\t\texpect(l).toContain(\"gender\");\n\t\t});\n\n\t\tit(\"offers gender codes in HTTP mode body\", async () => {\n\t\t\tconst doc =\n\t\t\t\t'PUT /fhir/Patient/1\\n\\n{\\n \"resourceType\": \"Patient\",\\n \"gender\": \"|\\n}';\n\t\t\tconst { cc } = completionAt(doc);\n\t\t\tconst result = await source(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"male\");\n\t\t\texpect(l).toContain(\"female\");\n\t\t});\n\n\t\tit(\"offers Observation fields inside Bundle entry.resource via hint\", async () => {\n\t\t\tconst hintSource = jsonCompletionSource(\n\t\t\t\tmockGetSDs,\n\t\t\t\t\"Bundle\",\n\t\t\t\tmockExpandValueSet,\n\t\t\t);\n\t\t\tconst doc =\n\t\t\t\t'POST /fhir/Bundle\\nContent-Type: application/json\\n\\n{\\n \"entry\": [\\n {\\n \"resource\": {\\n \"resourceType\": \"Observation\",\\n |\\n }\\n }\\n ]\\n}';\n\t\t\tconst { cc } = completionAt(doc);\n\t\t\tconst result = await hintSource(cc);\n\t\t\tconst l = labels(result);\n\t\t\texpect(l).toContain(\"status\");\n\t\t\texpect(l).toContain(\"code\");\n\t\t\texpect(l).toContain(\"subject\");\n\t\t\texpect(l).not.toContain(\"type\");\n\t\t});\n\t});\n});\n\ndescribe(\"buildParameterSnippet\", () => {\n\tit(\"inserts valueString by default when no value types\", () => {\n\t\tconst { text, cursorOffset } = buildParameterSnippet(\"package\", [], \" \");\n\t\texpect(text).toContain('\"name\": \"package\"');\n\t\texpect(text).toContain('\"valueString\": \"\"');\n\t\t// Cursor should be inside the empty valueString quotes\n\t\texpect(text[cursorOffset - 1]).toBe('\"');\n\t\texpect(text[cursorOffset]).toBe('\"');\n\t});\n\n\tit(\"inserts valueString for string-constrained type\", () => {\n\t\tconst { text } = buildParameterSnippet(\"label\", [\"string\"], \" \");\n\t\texpect(text).toContain('\"name\": \"label\"');\n\t\texpect(text).toContain('\"valueString\": \"\"');\n\t});\n\n\tit(\"inserts valueCode for code-constrained type\", () => {\n\t\tconst { text } = buildParameterSnippet(\"status\", [\"code\"], \" \");\n\t\texpect(text).toContain('\"name\": \"status\"');\n\t\texpect(text).toContain('\"valueCode\": \"\"');\n\t});\n\n\tit(\"inserts valueInteger for integer-constrained type\", () => {\n\t\tconst { text, cursorOffset } = buildParameterSnippet(\n\t\t\t\"count\",\n\t\t\t[\"integer\"],\n\t\t\t\" \",\n\t\t);\n\t\texpect(text).toContain('\"name\": \"count\"');\n\t\texpect(text).toContain('\"valueInteger\": ');\n\t\texpect(text).not.toContain('\"valueString\"');\n\t\t// Cursor should be after \": \"\n\t\texpect(text.slice(cursorOffset - 2, cursorOffset)).toBe(\": \");\n\t});\n\n\tit(\"inserts valueBoolean for boolean-constrained type\", () => {\n\t\tconst { text } = buildParameterSnippet(\"active\", [\"boolean\"], \" \");\n\t\texpect(text).toContain('\"name\": \"active\"');\n\t\texpect(text).toContain('\"valueBoolean\": ');\n\t});\n\n\tit(\"inserts complex object for CodeableConcept type\", () => {\n\t\tconst { text } = buildParameterSnippet(\"code\", [\"CodeableConcept\"], \" \");\n\t\texpect(text).toContain('\"name\": \"code\"');\n\t\texpect(text).toContain('\"valueCodeableConcept\": {');\n\t\texpect(text).toContain(\"}\");\n\t});\n\n\tit(\"uses correct indentation\", () => {\n\t\tconst { text } = buildParameterSnippet(\"test\", [], \" \");\n\t\tconst lines = text.split(\"\\n\");\n\t\t// Line 0: {\n\t\texpect(lines[0]).toBe(\"{\");\n\t\t// Line 1: inner indent + \"name\"\n\t\texpect(lines[1]).toMatch(/^ {4}\"name\": \"test\",$/);\n\t\t// Line 2: inner indent + \"valueString\"\n\t\texpect(lines[2]).toMatch(/^ {4}\"valueString\": \"\"$/);\n\t\t// Line 3: outer indent + }\n\t\texpect(lines[3]).toBe(\" }\");\n\t});\n\n\tit(\"inserts empty name for generic template with cursor in name\", () => {\n\t\tconst { text, cursorOffset } = buildParameterSnippet(\"\", [], \" \");\n\t\texpect(text).toContain('\"name\": \"\"');\n\t\texpect(text).toContain('\"valueString\": \"\"');\n\t\t// Cursor should be inside the name quotes (first \"\"), not valueString\n\t\tconst nameQuoteIdx = text.indexOf('\"name\": \"\"') + '\"name\": \"'.length;\n\t\texpect(cursorOffset).toBe(nameQuoteIdx);\n\t});\n});\n"],"names":["CompletionContext","json","EditorState","describe","expect","it","buildParameterSnippet","jsonCompletionSource","PATIENT_SD","type","url","baseDefinition","differential","element","path","min","max","code","binding","valueSet","strength","targetProfile","OBSERVATION_SD","DOMAIN_RESOURCE_SD","RESOURCE_SD","HUMAN_NAME_SD","REFERENCE_SD","META_SD","BUNDLE_SD","PARAMETERS_SD","contentReference","INSTALL_PARAMS_PROFILE","sliceName","fixedString","TYPED_PARAMS_PROFILE","TOPIC_DEST_SD","TOPIC_DEST_KAFKA_PROFILE","RESOURCE_TYPE_LIST","ALL_SDS","Patient","Observation","DomainResource","Resource","HumanName","Reference","Meta","Bundle","Parameters","AidboxTopicDestination","mockGetSDs","params","kind","derivation","sd","mockExpandValueSet","_filter","display","completionAt","doc","marker","pos","indexOf","text","slice","state","create","extensions","cc","labels","result","options","map","o","label","source","undefined","l","toContain","not","toBe","hintSource","toHaveLength","typedSource","option","find","toBeDefined","boost","info","cursorOffset","lines","split","toMatch","nameQuoteIdx","length"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,IAAI,QAAQ,wBAAwB;AAC7C,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAS;AAC9C,SACCC,qBAAqB,EAGrBC,oBAAoB,QACd,yBAAsB;AAE7B,0EAA0E;AAE1E,MAAMC,aAAa;IAClBC,MAAM;IACNC,KAAK;IACLC,gBAAgB;IAChBC,cAAc;QACbC,SAAS;YACR;gBAAEC,MAAM;gBAAWC,KAAK;gBAAGC,KAAK;YAAI;YACpC;gBAAEF,MAAM;gBAAgBC,KAAK;gBAAGC,KAAK;gBAAKP,MAAM;oBAAC;wBAAEQ,MAAM;oBAAY;iBAAE;YAAC;YACxE;gBACCH,MAAM;gBACNC,KAAK;gBACLC,KAAK;gBACLP,MAAM;oBAAC;wBAAEQ,MAAM;oBAAO;iBAAE;gBACxBC,SAAS;oBACRC,UAAU;oBACVC,UAAU;gBACX;YACD;YACA;gBAAEN,MAAM;gBAAqBC,KAAK;gBAAGC,KAAK;gBAAKP,MAAM;oBAAC;wBAAEQ,MAAM;oBAAO;iBAAE;YAAC;YACxE;gBAAEH,MAAM;gBAAkBC,KAAK;gBAAGC,KAAK;gBAAKP,MAAM;oBAAC;wBAAEQ,MAAM;oBAAU;iBAAE;YAAC;YACxE;gBACCH,MAAM;gBACNC,KAAK;gBAC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QACvB,sEAAsE;QACtE,MAAMe,eAAe9B,KAAKD,OAAO,CAAC,gBAAgB,YAAYgC,MAAM;QACpEzF,OAAOoF,cAAcT,IAAI,CAACa;IAC3B;AACD"}
@@ -1,4 +1,12 @@
1
1
  import { type Language, LanguageSupport } from "@codemirror/language";
2
- declare function http(bodyLanguages: (contentType: string) => Language | null): LanguageSupport;
2
+ export interface UrlSuggestion {
3
+ label: string;
4
+ value: string;
5
+ type?: string;
6
+ description?: string;
7
+ expression?: string;
8
+ }
9
+ export type GetUrlSuggestions = (path: string, method: string) => UrlSuggestion[] | Promise<UrlSuggestion[]>;
10
+ declare function http(bodyLanguages: (contentType: string) => Language | null, getUrlSuggestions?: GetUrlSuggestions): LanguageSupport;
3
11
  export { http };
4
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,QAAQ,EACb,eAAe,EAEf,MAAM,sBAAsB,CAAC;AA0E9B,iBAAS,IAAI,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,mBAIpE;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,QAAQ,EACb,eAAe,EAGf,MAAM,sBAAsB,CAAC;AA4T9B,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,KACV,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AAoEhD,iBAAS,IAAI,CACZ,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,EACvD,iBAAiB,CAAC,EAAE,iBAAiB,mBAiBrC;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -1,7 +1,10 @@
1
- import { foldInside, foldNodeProp, LanguageSupport, LRLanguage } from "@codemirror/language";
1
+ import { foldInside, foldNodeProp, LanguageSupport, LRLanguage, syntaxTree } from "@codemirror/language";
2
+ import { RangeSetBuilder } from "@codemirror/state";
3
+ import { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
2
4
  import { parseMixed } from "@lezer/common";
3
5
  import { styleTags, tags } from "@lezer/highlight";
4
6
  import { parser } from "./grammar/http.js";
7
+ import { HttpRequestMethod } from "./grammar/http.terms.js";
5
8
  function makeParser(bodyLanguages) {
6
9
  return parser.configure({
7
10
  props: [
@@ -54,12 +57,429 @@ function makeParser(bodyLanguages) {
54
57
  })
55
58
  });
56
59
  }
57
- function http(bodyLanguages) {
60
+ const methodDecorations = {
61
+ GET: Decoration.mark({
62
+ class: "cm-http-method-get"
63
+ }),
64
+ POST: Decoration.mark({
65
+ class: "cm-http-method-post"
66
+ }),
67
+ PUT: Decoration.mark({
68
+ class: "cm-http-method-put"
69
+ }),
70
+ PATCH: Decoration.mark({
71
+ class: "cm-http-method-patch"
72
+ }),
73
+ DELETE: Decoration.mark({
74
+ class: "cm-http-method-delete"
75
+ })
76
+ };
77
+ function buildMethodDecorations(view) {
78
+ const builder = new RangeSetBuilder();
79
+ const tree = syntaxTree(view.state);
80
+ tree.iterate({
81
+ enter (node) {
82
+ if (node.type.id === HttpRequestMethod) {
83
+ const text = view.state.sliceDoc(node.from, node.to).toUpperCase();
84
+ const deco = methodDecorations[text];
85
+ if (deco) {
86
+ builder.add(node.from, node.to, deco);
87
+ }
88
+ }
89
+ }
90
+ });
91
+ return builder.finish();
92
+ }
93
+ const httpMethodHighlighter = ViewPlugin.fromClass(class {
94
+ decorations;
95
+ constructor(view){
96
+ this.decorations = buildMethodDecorations(view);
97
+ }
98
+ update(update) {
99
+ if (update.docChanged || update.viewportChanged) {
100
+ this.decorations = buildMethodDecorations(update.view);
101
+ }
102
+ }
103
+ }, {
104
+ decorations: (v)=>v.decorations
105
+ });
106
+ const httpMethodTheme = EditorView.baseTheme({
107
+ ".cm-http-method-get": {
108
+ color: "var(--color-utility-green)"
109
+ },
110
+ ".cm-http-method-post": {
111
+ color: "var(--color-utility-yellow)"
112
+ },
113
+ ".cm-http-method-put": {
114
+ color: "var(--color-utility-blue)"
115
+ },
116
+ ".cm-http-method-patch": {
117
+ color: "var(--color-utility-violet)"
118
+ },
119
+ ".cm-http-method-delete": {
120
+ color: "var(--color-utility-red)"
121
+ }
122
+ });
123
+ import { HttpHeaderName, HttpHeaders, HttpHeaderValue, HttpRequestPath } from "./grammar/http.terms.js";
124
+ const COMMON_HEADERS = [
125
+ // Standard HTTP
126
+ {
127
+ label: "Accept",
128
+ type: "header",
129
+ apply: "Accept: "
130
+ },
131
+ {
132
+ label: "Accept-Encoding",
133
+ type: "header",
134
+ apply: "Accept-Encoding: "
135
+ },
136
+ {
137
+ label: "Accept-Language",
138
+ type: "header",
139
+ apply: "Accept-Language: "
140
+ },
141
+ {
142
+ label: "Authorization",
143
+ type: "header",
144
+ apply: "Authorization: "
145
+ },
146
+ {
147
+ label: "Cache-Control",
148
+ type: "header",
149
+ apply: "Cache-Control: "
150
+ },
151
+ {
152
+ label: "Content-Type",
153
+ type: "header",
154
+ apply: "Content-Type: "
155
+ },
156
+ {
157
+ label: "Cookie",
158
+ type: "header",
159
+ apply: "Cookie: "
160
+ },
161
+ {
162
+ label: "Host",
163
+ type: "header",
164
+ apply: "Host: "
165
+ },
166
+ {
167
+ label: "If-Match",
168
+ type: "header",
169
+ apply: "If-Match: "
170
+ },
171
+ {
172
+ label: "If-Modified-Since",
173
+ type: "header",
174
+ apply: "If-Modified-Since: "
175
+ },
176
+ {
177
+ label: "If-None-Match",
178
+ type: "header",
179
+ apply: "If-None-Match: "
180
+ },
181
+ {
182
+ label: "Origin",
183
+ type: "header",
184
+ apply: "Origin: "
185
+ },
186
+ {
187
+ label: "Prefer",
188
+ type: "header",
189
+ apply: "Prefer: "
190
+ },
191
+ // Aidbox-specific
192
+ {
193
+ label: "x-audit",
194
+ type: "header",
195
+ apply: "x-audit: "
196
+ },
197
+ {
198
+ label: "x-correlation-id",
199
+ type: "header",
200
+ apply: "x-correlation-id: "
201
+ },
202
+ {
203
+ label: "x-debug",
204
+ type: "header",
205
+ apply: "x-debug: "
206
+ },
207
+ {
208
+ label: "x-external-user-id",
209
+ type: "header",
210
+ apply: "x-external-user-id: "
211
+ },
212
+ {
213
+ label: "x-max-isolation-level",
214
+ type: "header",
215
+ apply: "x-max-isolation-level: "
216
+ },
217
+ {
218
+ label: "x-original-uri",
219
+ type: "header",
220
+ apply: "x-original-uri: "
221
+ },
222
+ {
223
+ label: "x-request-id",
224
+ type: "header",
225
+ apply: "x-request-id: "
226
+ },
227
+ {
228
+ label: "x-use-ro-replica",
229
+ type: "header",
230
+ apply: "x-use-ro-replica: "
231
+ },
232
+ {
233
+ label: "su",
234
+ type: "header",
235
+ apply: "su: "
236
+ },
237
+ {
238
+ label: "traceparent",
239
+ type: "header",
240
+ apply: "traceparent: "
241
+ }
242
+ ];
243
+ // Header value completions by header name
244
+ const HEADER_VALUES = {
245
+ "content-type": [
246
+ {
247
+ label: "application/json",
248
+ type: "text"
249
+ },
250
+ {
251
+ label: "application/fhir+json",
252
+ type: "text"
253
+ },
254
+ {
255
+ label: "text/yaml",
256
+ type: "text"
257
+ },
258
+ {
259
+ label: "application/ndjson",
260
+ type: "text"
261
+ },
262
+ {
263
+ label: "application/gzip",
264
+ type: "text"
265
+ },
266
+ {
267
+ label: "text/csv",
268
+ type: "text"
269
+ }
270
+ ],
271
+ accept: [
272
+ {
273
+ label: "application/json",
274
+ type: "text"
275
+ },
276
+ {
277
+ label: "application/yaml",
278
+ type: "text"
279
+ },
280
+ {
281
+ label: "text/yaml",
282
+ type: "text"
283
+ }
284
+ ],
285
+ prefer: [
286
+ {
287
+ label: "respond-async",
288
+ type: "text"
289
+ },
290
+ {
291
+ label: "return=minimal",
292
+ type: "text"
293
+ },
294
+ {
295
+ label: "return=representation",
296
+ type: "text"
297
+ },
298
+ {
299
+ label: "return=OperationOutcome",
300
+ type: "text"
301
+ }
302
+ ],
303
+ "x-debug": [
304
+ {
305
+ label: "policy",
306
+ type: "text"
307
+ }
308
+ ],
309
+ "x-max-isolation-level": [
310
+ {
311
+ label: "read-committed",
312
+ type: "text"
313
+ },
314
+ {
315
+ label: "repeatable-read",
316
+ type: "text"
317
+ },
318
+ {
319
+ label: "serializable",
320
+ type: "text"
321
+ }
322
+ ],
323
+ "cache-control": [
324
+ {
325
+ label: "no-cache",
326
+ type: "text"
327
+ },
328
+ {
329
+ label: "no-store",
330
+ type: "text"
331
+ },
332
+ {
333
+ label: "max-age=0",
334
+ type: "text"
335
+ }
336
+ ],
337
+ authorization: [
338
+ {
339
+ label: "Bearer ",
340
+ type: "text"
341
+ },
342
+ {
343
+ label: "Basic ",
344
+ type: "text"
345
+ }
346
+ ]
347
+ };
348
+ const HTTP_METHODS = [
349
+ "GET",
350
+ "POST",
351
+ "PUT",
352
+ "PATCH",
353
+ "DELETE"
354
+ ].map((method)=>({
355
+ label: method,
356
+ type: "keyword",
357
+ apply: (view, _c, from, to)=>{
358
+ const line = view.state.doc.lineAt(from);
359
+ const afterTo = line.text.slice(to - line.from);
360
+ // Skip whitespace after the method word to avoid double spaces
361
+ const wsMatch = afterTo.match(/^(\s*)/);
362
+ const actualTo = to + (wsMatch?.[1]?.length ?? 0);
363
+ const rest = line.text.slice(actualTo - line.from);
364
+ const insert = rest.startsWith("/") ? `${method} ` : `${method} /`;
365
+ view.dispatch({
366
+ changes: {
367
+ from,
368
+ to: actualTo,
369
+ insert
370
+ },
371
+ selection: {
372
+ anchor: from + insert.length
373
+ }
374
+ });
375
+ }
376
+ }));
377
+ function httpCompletionSource(context) {
378
+ const { state, pos } = context;
379
+ const tree = syntaxTree(state);
380
+ const node = tree.resolveInner(pos, -1);
381
+ const line = state.doc.lineAt(pos);
382
+ const beforeCursor = line.text.slice(0, pos - line.from);
383
+ // Request method completion — first line, typing method
384
+ if (node.type.id === HttpRequestMethod || line.number === 1 && /^\s*[a-zA-Z]*$/.test(beforeCursor)) {
385
+ const word = context.matchBefore(/[a-zA-Z]*/);
386
+ return {
387
+ from: word?.from ?? pos,
388
+ options: HTTP_METHODS,
389
+ validFor: /^[a-zA-Z]*$/i
390
+ };
391
+ }
392
+ // Header value completion — after colon
393
+ const colonIdx = beforeCursor.indexOf(":");
394
+ if (colonIdx >= 0) {
395
+ const inHeaderValue = node.type.id === HttpHeaderValue;
396
+ const parentIsHeaders = node.parent?.type.id === HttpHeaders;
397
+ if (!inHeaderValue && !parentIsHeaders && node.parent?.parent?.type.id !== HttpHeaders) return null;
398
+ const headerName = beforeCursor.slice(0, colonIdx).trim().toLowerCase();
399
+ const values = HEADER_VALUES[headerName];
400
+ if (!values) return null;
401
+ const word = context.matchBefore(/\S*/);
402
+ return {
403
+ from: word?.from ?? pos,
404
+ options: values,
405
+ validFor: /^\S*$/
406
+ };
407
+ }
408
+ // Header name completion — before colon
409
+ const inHeaderName = node.type.id === HttpHeaderName;
410
+ const inHeaders = node.type.id === HttpHeaders;
411
+ const parentIsHeaders = node.parent?.type.id === HttpHeaders;
412
+ if (!inHeaderName && !inHeaders && !parentIsHeaders) return null;
413
+ const word = context.matchBefore(/[\w-]+/);
414
+ if (!word) return null;
415
+ return {
416
+ from: word.from,
417
+ options: COMMON_HEADERS,
418
+ validFor: /^[\w-]+$/
419
+ };
420
+ }
421
+ function httpUrlCompletionSource(getUrlSuggestions) {
422
+ return async (context)=>{
423
+ const { state, pos } = context;
424
+ const tree = syntaxTree(state);
425
+ const node = tree.resolveInner(pos, -1);
426
+ if (node.type.id !== HttpRequestPath) return null;
427
+ const line = state.doc.lineAt(pos);
428
+ const lineText = line.text;
429
+ // Extract method from the beginning of the line
430
+ const methodMatch = lineText.match(/^\s*(\w+)\s+/);
431
+ if (!methodMatch?.[1]) return null;
432
+ const method = methodMatch[1].toUpperCase();
433
+ const pathStart = line.from + methodMatch[0].length;
434
+ const currentPath = state.sliceDoc(pathStart, pos);
435
+ const suggestions = await getUrlSuggestions(currentPath, method);
436
+ if (suggestions.length === 0) return null;
437
+ const options = suggestions.map((s)=>{
438
+ const c = {
439
+ label: s.label,
440
+ type: s.type === "resource-type" ? "type" : s.type === "operation" ? "function" : s.type === "search-param" ? "search-param" : "text"
441
+ };
442
+ if (s.type === "search-param") c.apply = `${s.label}=`;
443
+ else if (s.type === "path" && s.label === "fhir") c.apply = `${s.label}/`;
444
+ if (s.description) c.detail = s.description.toUpperCase();
445
+ if (s.expression) c.info = s.expression;
446
+ return c;
447
+ });
448
+ // Match from the last segment separator (/ or ? or &)
449
+ const hasQuery = currentPath.includes("?");
450
+ let from;
451
+ if (hasQuery) {
452
+ const lastSep = Math.max(currentPath.lastIndexOf("?"), currentPath.lastIndexOf("&"));
453
+ from = pathStart + lastSep + 1;
454
+ } else {
455
+ const lastSlash = currentPath.lastIndexOf("/");
456
+ from = pathStart + lastSlash + 1;
457
+ }
458
+ return {
459
+ from,
460
+ options,
461
+ validFor: /^[^\s&=]*/
462
+ };
463
+ };
464
+ }
465
+ function http(bodyLanguages, getUrlSuggestions) {
58
466
  const parser = makeParser(bodyLanguages);
59
467
  const language = LRLanguage.define({
60
468
  parser: parser
61
469
  });
62
- return new LanguageSupport(language, []);
470
+ const extensions = [
471
+ httpMethodHighlighter,
472
+ httpMethodTheme,
473
+ language.data.of({
474
+ autocomplete: httpCompletionSource
475
+ })
476
+ ];
477
+ if (getUrlSuggestions) {
478
+ extensions.push(language.data.of({
479
+ autocomplete: httpUrlCompletionSource(getUrlSuggestions)
480
+ }));
481
+ }
482
+ return new LanguageSupport(language, extensions);
63
483
  }
64
484
  export { http };
65
485