@intentius/chant-lexicon-docker 0.124.97 → 0.124.99

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 (241) hide show
  1. package/dist/codegen/docs-cli.d.ts +0 -1
  2. package/dist/codegen/docs.d.ts +0 -1
  3. package/dist/codegen/generate-cli.d.ts +0 -1
  4. package/dist/codegen/generate-compose.d.ts +0 -1
  5. package/dist/codegen/generate-dockerfile.d.ts +0 -1
  6. package/dist/codegen/generate.d.ts +0 -1
  7. package/dist/codegen/naming.d.ts +0 -1
  8. package/dist/codegen/package.d.ts +0 -1
  9. package/dist/codegen/patches.d.ts +0 -1
  10. package/dist/codegen/versions.d.ts +0 -1
  11. package/dist/compose-key.d.ts +0 -1
  12. package/dist/composites/catalog.d.ts +0 -1
  13. package/dist/composites/docker-otel-collector.d.ts +0 -1
  14. package/dist/composites/docker-web-service.d.ts +0 -1
  15. package/dist/composites/index.d.ts +0 -1
  16. package/dist/coverage.d.ts +0 -1
  17. package/dist/default-labels.d.ts +0 -1
  18. package/dist/detect.d.ts +0 -1
  19. package/dist/dockerfile-order.d.ts +0 -1
  20. package/dist/export-resources.d.ts +0 -1
  21. package/dist/generated/index.d.ts +0 -1
  22. package/dist/generated/runtime.d.ts +0 -1
  23. package/dist/import/adapter.d.ts +0 -1
  24. package/dist/import/adapter.js +4 -2
  25. package/dist/import/embedded.d.ts +0 -1
  26. package/dist/import/engine.d.ts +0 -1
  27. package/dist/import/generator.d.ts +9 -2
  28. package/dist/import/generator.js +23 -1
  29. package/dist/import/live-export.d.ts +0 -1
  30. package/dist/import/parser.d.ts +0 -1
  31. package/dist/import/testdata/tar.d.ts +0 -1
  32. package/dist/index.d.ts +0 -1
  33. package/dist/integrity.json +2 -2
  34. package/dist/interpolation.d.ts +0 -1
  35. package/dist/lint/audit-catalog.d.ts +0 -1
  36. package/dist/lint/audit-lineage.d.ts +0 -1
  37. package/dist/lint/post-synth/add-url-checksum.d.ts +0 -1
  38. package/dist/lint/post-synth/apt-no-recommends.d.ts +0 -1
  39. package/dist/lint/post-synth/apt-update-alone.d.ts +0 -1
  40. package/dist/lint/post-synth/cache-busting-copy.d.ts +0 -1
  41. package/dist/lint/post-synth/copy-from-stage.d.ts +0 -1
  42. package/dist/lint/post-synth/docker-helpers.d.ts +0 -1
  43. package/dist/lint/post-synth/index.d.ts +0 -1
  44. package/dist/lint/post-synth/no-latest-image.d.ts +0 -1
  45. package/dist/lint/post-synth/no-root-user.d.ts +0 -1
  46. package/dist/lint/post-synth/prefer-copy.d.ts +0 -1
  47. package/dist/lint/post-synth/relative-workdir.d.ts +0 -1
  48. package/dist/lint/post-synth/repeated-cmd.d.ts +0 -1
  49. package/dist/lint/post-synth/root-after-user.d.ts +0 -1
  50. package/dist/lint/post-synth/ssh-port-exposed.d.ts +0 -1
  51. package/dist/lint/post-synth/unused-global-arg.d.ts +0 -1
  52. package/dist/lint/post-synth/unused-volume.d.ts +0 -1
  53. package/dist/lint/rules/data/deprecated-images.d.ts +0 -1
  54. package/dist/lint/rules/data/known-base-images.d.ts +0 -1
  55. package/dist/lint/rules/index.d.ts +0 -1
  56. package/dist/lint/rules/no-latest-tag.d.ts +0 -1
  57. package/dist/lint/rules/per-kind-order.d.ts +0 -1
  58. package/dist/list-artifacts.d.ts +0 -1
  59. package/dist/lsp/completions.d.ts +0 -1
  60. package/dist/lsp/hover.d.ts +0 -1
  61. package/dist/manifest.json +1 -1
  62. package/dist/package-cli.d.ts +0 -1
  63. package/dist/plugin.d.ts +0 -1
  64. package/dist/serializer.d.ts +0 -1
  65. package/dist/spec/fetch-compose.d.ts +0 -1
  66. package/dist/spec/fetch-engine.d.ts +0 -1
  67. package/dist/spec/parse-compose.d.ts +0 -1
  68. package/dist/spec/parse-engine.d.ts +0 -1
  69. package/dist/validate-cli.d.ts +0 -1
  70. package/dist/validate.d.ts +0 -1
  71. package/dist/variables.d.ts +0 -1
  72. package/package.json +4 -5
  73. package/dist/codegen/docs-cli.d.ts.map +0 -1
  74. package/dist/codegen/docs.d.ts.map +0 -1
  75. package/dist/codegen/generate-cli.d.ts.map +0 -1
  76. package/dist/codegen/generate-compose.d.ts.map +0 -1
  77. package/dist/codegen/generate-dockerfile.d.ts.map +0 -1
  78. package/dist/codegen/generate.d.ts.map +0 -1
  79. package/dist/codegen/naming.d.ts.map +0 -1
  80. package/dist/codegen/package.d.ts.map +0 -1
  81. package/dist/codegen/patches.d.ts.map +0 -1
  82. package/dist/codegen/versions.d.ts.map +0 -1
  83. package/dist/compose-key.d.ts.map +0 -1
  84. package/dist/composites/catalog.d.ts.map +0 -1
  85. package/dist/composites/docker-otel-collector.d.ts.map +0 -1
  86. package/dist/composites/docker-web-service.d.ts.map +0 -1
  87. package/dist/composites/index.d.ts.map +0 -1
  88. package/dist/coverage.d.ts.map +0 -1
  89. package/dist/default-labels.d.ts.map +0 -1
  90. package/dist/detect.d.ts.map +0 -1
  91. package/dist/dockerfile-order.d.ts.map +0 -1
  92. package/dist/export-resources.d.ts.map +0 -1
  93. package/dist/generated/index.d.ts.map +0 -1
  94. package/dist/generated/runtime.d.ts.map +0 -1
  95. package/dist/import/adapter.d.ts.map +0 -1
  96. package/dist/import/embedded.d.ts.map +0 -1
  97. package/dist/import/engine.d.ts.map +0 -1
  98. package/dist/import/generator.d.ts.map +0 -1
  99. package/dist/import/live-export.d.ts.map +0 -1
  100. package/dist/import/parser.d.ts.map +0 -1
  101. package/dist/import/testdata/tar.d.ts.map +0 -1
  102. package/dist/index.d.ts.map +0 -1
  103. package/dist/interpolation.d.ts.map +0 -1
  104. package/dist/lint/audit-catalog.d.ts.map +0 -1
  105. package/dist/lint/audit-lineage.d.ts.map +0 -1
  106. package/dist/lint/post-synth/add-url-checksum.d.ts.map +0 -1
  107. package/dist/lint/post-synth/apt-no-recommends.d.ts.map +0 -1
  108. package/dist/lint/post-synth/apt-update-alone.d.ts.map +0 -1
  109. package/dist/lint/post-synth/cache-busting-copy.d.ts.map +0 -1
  110. package/dist/lint/post-synth/copy-from-stage.d.ts.map +0 -1
  111. package/dist/lint/post-synth/docker-helpers.d.ts.map +0 -1
  112. package/dist/lint/post-synth/index.d.ts.map +0 -1
  113. package/dist/lint/post-synth/no-latest-image.d.ts.map +0 -1
  114. package/dist/lint/post-synth/no-root-user.d.ts.map +0 -1
  115. package/dist/lint/post-synth/prefer-copy.d.ts.map +0 -1
  116. package/dist/lint/post-synth/relative-workdir.d.ts.map +0 -1
  117. package/dist/lint/post-synth/repeated-cmd.d.ts.map +0 -1
  118. package/dist/lint/post-synth/root-after-user.d.ts.map +0 -1
  119. package/dist/lint/post-synth/ssh-port-exposed.d.ts.map +0 -1
  120. package/dist/lint/post-synth/unused-global-arg.d.ts.map +0 -1
  121. package/dist/lint/post-synth/unused-volume.d.ts.map +0 -1
  122. package/dist/lint/rules/data/deprecated-images.d.ts.map +0 -1
  123. package/dist/lint/rules/data/known-base-images.d.ts.map +0 -1
  124. package/dist/lint/rules/index.d.ts.map +0 -1
  125. package/dist/lint/rules/no-latest-tag.d.ts.map +0 -1
  126. package/dist/lint/rules/per-kind-order.d.ts.map +0 -1
  127. package/dist/list-artifacts.d.ts.map +0 -1
  128. package/dist/lsp/completions.d.ts.map +0 -1
  129. package/dist/lsp/hover.d.ts.map +0 -1
  130. package/dist/package-cli.d.ts.map +0 -1
  131. package/dist/plugin.d.ts.map +0 -1
  132. package/dist/serializer.d.ts.map +0 -1
  133. package/dist/spec/fetch-compose.d.ts.map +0 -1
  134. package/dist/spec/fetch-engine.d.ts.map +0 -1
  135. package/dist/spec/parse-compose.d.ts.map +0 -1
  136. package/dist/spec/parse-engine.d.ts.map +0 -1
  137. package/dist/validate-cli.d.ts.map +0 -1
  138. package/dist/validate.d.ts.map +0 -1
  139. package/dist/variables.d.ts.map +0 -1
  140. package/src/codegen/__snapshots__/okf.test.ts.snap +0 -555
  141. package/src/codegen/docs-cli.ts +0 -10
  142. package/src/codegen/docs.ts +0 -171
  143. package/src/codegen/generate-cli.ts +0 -36
  144. package/src/codegen/generate-compose.ts +0 -21
  145. package/src/codegen/generate-dockerfile.ts +0 -21
  146. package/src/codegen/generate.test.ts +0 -115
  147. package/src/codegen/generate.ts +0 -258
  148. package/src/codegen/naming.test.ts +0 -81
  149. package/src/codegen/naming.ts +0 -54
  150. package/src/codegen/okf.test.ts +0 -36
  151. package/src/codegen/package.ts +0 -59
  152. package/src/codegen/patches.ts +0 -42
  153. package/src/codegen/versions.ts +0 -46
  154. package/src/compose-key.ts +0 -31
  155. package/src/composites/catalog.test.ts +0 -39
  156. package/src/composites/catalog.ts +0 -118
  157. package/src/composites/docker-otel-collector.ts +0 -83
  158. package/src/composites/docker-web-service.test.ts +0 -34
  159. package/src/composites/docker-web-service.ts +0 -75
  160. package/src/composites/index.ts +0 -9
  161. package/src/coverage.test.ts +0 -33
  162. package/src/coverage.ts +0 -54
  163. package/src/default-labels.test.ts +0 -85
  164. package/src/default-labels.ts +0 -72
  165. package/src/detect.ts +0 -7
  166. package/src/dockerfile-order.ts +0 -20
  167. package/src/docs-examples.test.ts +0 -141
  168. package/src/export-resources.ts +0 -90
  169. package/src/generated/index.d.ts +0 -407
  170. package/src/generated/index.ts +0 -410
  171. package/src/generated/runtime.ts +0 -4
  172. package/src/import/adapter.ts +0 -99
  173. package/src/import/embedded-live.test.ts +0 -248
  174. package/src/import/embedded.ts +0 -83
  175. package/src/import/engine.ts +0 -107
  176. package/src/import/generator.test.ts +0 -134
  177. package/src/import/generator.ts +0 -202
  178. package/src/import/live-export.test.ts +0 -271
  179. package/src/import/live-export.ts +0 -359
  180. package/src/import/parser.test.ts +0 -137
  181. package/src/import/parser.ts +0 -269
  182. package/src/import/roundtrip.test.ts +0 -257
  183. package/src/import/testdata/configs-secrets.yaml +0 -15
  184. package/src/import/testdata/full.yaml +0 -43
  185. package/src/import/testdata/names-and-fields.yaml +0 -44
  186. package/src/import/testdata/simple.yaml +0 -9
  187. package/src/import/testdata/tar.ts +0 -24
  188. package/src/import/testdata/webapp.yaml +0 -41
  189. package/src/index.ts +0 -32
  190. package/src/interpolation.test.ts +0 -41
  191. package/src/interpolation.ts +0 -76
  192. package/src/lint/audit-catalog.ts +0 -28
  193. package/src/lint/audit-lineage.ts +0 -48
  194. package/src/lint/post-synth/add-url-checksum.ts +0 -38
  195. package/src/lint/post-synth/apt-no-recommends.ts +0 -43
  196. package/src/lint/post-synth/apt-update-alone.ts +0 -39
  197. package/src/lint/post-synth/cache-busting-copy.ts +0 -65
  198. package/src/lint/post-synth/copy-from-stage.ts +0 -54
  199. package/src/lint/post-synth/docker-helpers.ts +0 -194
  200. package/src/lint/post-synth/index.ts +0 -33
  201. package/src/lint/post-synth/no-latest-image.ts +0 -36
  202. package/src/lint/post-synth/no-root-user.ts +0 -38
  203. package/src/lint/post-synth/post-synth.test.ts +0 -330
  204. package/src/lint/post-synth/prefer-copy.ts +0 -53
  205. package/src/lint/post-synth/relative-workdir.ts +0 -38
  206. package/src/lint/post-synth/repeated-cmd.ts +0 -35
  207. package/src/lint/post-synth/root-after-user.ts +0 -44
  208. package/src/lint/post-synth/ssh-port-exposed.ts +0 -68
  209. package/src/lint/post-synth/unused-global-arg.ts +0 -38
  210. package/src/lint/post-synth/unused-volume.ts +0 -49
  211. package/src/lint/rules/data/deprecated-images.ts +0 -28
  212. package/src/lint/rules/data/known-base-images.ts +0 -20
  213. package/src/lint/rules/index.ts +0 -6
  214. package/src/lint/rules/no-latest-tag.ts +0 -63
  215. package/src/lint/rules/per-kind-order.ts +0 -130
  216. package/src/lint/rules/rules.test.ts +0 -170
  217. package/src/list-artifacts.test.ts +0 -141
  218. package/src/list-artifacts.ts +0 -164
  219. package/src/lsp/completions.test.ts +0 -40
  220. package/src/lsp/completions.ts +0 -21
  221. package/src/lsp/hover.test.ts +0 -35
  222. package/src/lsp/hover.ts +0 -39
  223. package/src/package-cli.ts +0 -25
  224. package/src/plugin.test.ts +0 -121
  225. package/src/plugin.ts +0 -268
  226. package/src/serializer.test.ts +0 -545
  227. package/src/serializer.ts +0 -444
  228. package/src/skills/chant-docker-patterns.md +0 -222
  229. package/src/skills/chant-docker.md +0 -156
  230. package/src/spec/fetch-compose.ts +0 -35
  231. package/src/spec/fetch-engine.ts +0 -25
  232. package/src/spec/parse-compose.ts +0 -195
  233. package/src/spec/parse-engine.ts +0 -59
  234. package/src/typecheck.e2e.test.ts +0 -125
  235. package/src/typed-props.test.ts +0 -60
  236. package/src/validate-cli.ts +0 -19
  237. package/src/validate.test.ts +0 -16
  238. package/src/validate.ts +0 -44
  239. package/src/variables.test.ts +0 -32
  240. package/src/variables.ts +0 -47
  241. /package/{src → dist}/generated/lexicon-docker.json +0 -0
@@ -1,410 +0,0 @@
1
- // Code generated by chant generate. DO NOT EDIT.
2
- import { createResource } from "./runtime";
3
- import type { Declarable } from "@intentius/chant/declarable";
4
- import type { EnvIntrinsic } from "../interpolation";
5
-
6
- /** A docker resource constructor whose props are type-checked. */
7
- export type DockerResourceConstructor<P> = new (props?: P, attributes?: Record<string, unknown>) => InstanceType<ReturnType<typeof createResource>>;
8
-
9
- /**
10
- * A Compose string value: a string, an `env()` interpolation, or an entity
11
- * (service, network, volume, config, secret or Dockerfile), which is written as its name.
12
- */
13
- export type ComposeString = string | EnvIntrinsic | Declarable;
14
-
15
- /** A containerized service definition in Docker Compose */
16
- export interface ServiceProps {
17
- develop?: { watch?: Array<{ ignore?: ComposeString | Array<ComposeString>; include?: ComposeString | Array<ComposeString>; path: ComposeString; action: "rebuild" | "sync" | "restart" | "sync+restart" | "sync+exec"; target?: ComposeString; exec?: { command: null | ComposeString | Array<ComposeString>; user?: ComposeString; privileged?: boolean | ComposeString; working_dir?: ComposeString; environment?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; [key: `x-${string}`]: unknown }; initial_sync?: boolean; [key: `x-${string}`]: unknown }>; [key: `x-${string}`]: unknown } | null;
18
- deploy?: { mode?: ComposeString; endpoint_mode?: ComposeString; replicas?: number | ComposeString; labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; rollback_config?: { parallelism?: number | ComposeString; delay?: ComposeString; failure_action?: ComposeString; monitor?: ComposeString; max_failure_ratio?: number | ComposeString; order?: "start-first" | "stop-first"; [key: `x-${string}`]: unknown }; update_config?: { parallelism?: number | ComposeString; delay?: ComposeString; failure_action?: ComposeString; monitor?: ComposeString; max_failure_ratio?: number | ComposeString; order?: "start-first" | "stop-first"; [key: `x-${string}`]: unknown }; resources?: { limits?: { cpus?: number | ComposeString; memory?: ComposeString; pids?: number | ComposeString; [key: `x-${string}`]: unknown }; reservations?: { cpus?: number | ComposeString; memory?: ComposeString; generic_resources?: Array<{ discrete_resource_spec?: { kind?: ComposeString; value?: number | ComposeString; [key: `x-${string}`]: unknown }; [key: `x-${string}`]: unknown }>; devices?: Array<{ capabilities: Array<ComposeString>; count?: ComposeString | number; device_ids?: Array<ComposeString>; driver?: ComposeString; options?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; [key: `x-${string}`]: unknown }>; [key: `x-${string}`]: unknown }; [key: `x-${string}`]: unknown }; restart_policy?: { condition?: ComposeString; delay?: ComposeString; max_attempts?: number | ComposeString; window?: ComposeString; [key: `x-${string}`]: unknown }; placement?: { constraints?: Array<ComposeString>; preferences?: Array<{ spread?: ComposeString; [key: `x-${string}`]: unknown }>; max_replicas_per_node?: number | ComposeString; [key: `x-${string}`]: unknown }; [key: `x-${string}`]: unknown } | null;
19
- annotations?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
20
- attach?: boolean | ComposeString;
21
- /** Configuration options for building the service's image. */
22
- build?: ComposeString | { context?: ComposeString; dockerfile?: ComposeString; dockerfile_inline?: ComposeString; entitlements?: Array<ComposeString>; args?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; ssh?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; cache_from?: Array<ComposeString>; cache_to?: Array<ComposeString>; no_cache?: boolean | ComposeString; no_cache_filter?: ComposeString | Array<ComposeString>; additional_contexts?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; network?: ComposeString; provenance?: ComposeString | boolean; sbom?: ComposeString | boolean; pull?: boolean | ComposeString; target?: ComposeString; shm_size?: number | ComposeString; extra_hosts?: Record<string, ComposeString | Array<ComposeString>> | Array<ComposeString>; isolation?: ComposeString; privileged?: boolean | ComposeString; secrets?: Array<ComposeString | { source?: ComposeString; target?: ComposeString; uid?: ComposeString; gid?: ComposeString; mode?: number | ComposeString; [key: `x-${string}`]: unknown }>; tags?: Array<ComposeString>; ulimits?: Record<string, number | ComposeString | { hard: number | ComposeString; soft: number | ComposeString; [key: `x-${string}`]: unknown }>; platforms?: Array<ComposeString>; [key: `x-${string}`]: unknown };
23
- /** Block IO configuration for the service. */
24
- blkio_config?: { device_read_bps?: Array<{ path?: ComposeString; rate?: number | ComposeString }>; device_read_iops?: Array<{ path?: ComposeString; rate?: number | ComposeString }>; device_write_bps?: Array<{ path?: ComposeString; rate?: number | ComposeString }>; device_write_iops?: Array<{ path?: ComposeString; rate?: number | ComposeString }>; weight?: number | ComposeString; weight_device?: Array<{ path?: ComposeString; weight?: number | ComposeString }> };
25
- /** Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'. */
26
- cap_add?: Array<ComposeString>;
27
- /** Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'. */
28
- cap_drop?: Array<ComposeString>;
29
- /** Specify the cgroup namespace to join. Use 'host' to use the host's cgroup namespace, or 'private' to use a private cgroup namespace. */
30
- cgroup?: "host" | "private";
31
- /** Specify an optional parent cgroup for the container. */
32
- cgroup_parent?: ComposeString;
33
- /** Override the default command declared by the container image, for example 'CMD' in Dockerfile. */
34
- command?: null | ComposeString | Array<ComposeString>;
35
- /** Grant access to Configs on a per-service basis. */
36
- configs?: Array<ComposeString | { source?: ComposeString; target?: ComposeString; uid?: ComposeString; gid?: ComposeString; mode?: number | ComposeString; [key: `x-${string}`]: unknown }>;
37
- /** Specify a custom container name, rather than a generated default name. */
38
- container_name?: ComposeString;
39
- /** Number of usable CPUs. */
40
- cpu_count?: ComposeString | number;
41
- /** Percentage of CPU resources to use. */
42
- cpu_percent?: ComposeString | number;
43
- /** CPU shares (relative weight) for the container. */
44
- cpu_shares?: number | ComposeString;
45
- /** Limit the CPU CFS (Completely Fair Scheduler) quota. */
46
- cpu_quota?: number | ComposeString;
47
- /** Limit the CPU CFS (Completely Fair Scheduler) period. */
48
- cpu_period?: number | ComposeString;
49
- /** Limit the CPU real-time period in microseconds or a duration. */
50
- cpu_rt_period?: number | ComposeString;
51
- /** Limit the CPU real-time runtime in microseconds or a duration. */
52
- cpu_rt_runtime?: number | ComposeString;
53
- /** Number of CPUs to use. A floating-point value is supported to request partial CPUs. */
54
- cpus?: number | ComposeString;
55
- /** CPUs in which to allow execution (0-3, 0,1). */
56
- cpuset?: ComposeString;
57
- /** Configure the credential spec for managed service account. */
58
- credential_spec?: { config?: ComposeString; file?: ComposeString; registry?: ComposeString; [key: `x-${string}`]: unknown };
59
- /** Express dependency between services. Service dependencies cause services to be started in dependency order. The dependent service will wait for the dependency to be ready before starting. */
60
- depends_on?: Array<ComposeString> | Record<string, { restart?: boolean | ComposeString; required?: boolean; condition: "service_started" | "service_healthy" | "service_completed_successfully"; [key: `x-${string}`]: unknown }>;
61
- /** Add rules to the cgroup allowed devices list. */
62
- device_cgroup_rules?: Array<ComposeString>;
63
- /** List of device mappings for the container. */
64
- devices?: Array<ComposeString | { source: ComposeString; target?: ComposeString; permissions?: ComposeString; [key: `x-${string}`]: unknown }>;
65
- /** Custom DNS servers to set for the service container. */
66
- dns?: ComposeString | Array<ComposeString>;
67
- /** Custom DNS options to be passed to the container's DNS resolver. */
68
- dns_opt?: Array<ComposeString>;
69
- /** Custom DNS search domains to set on the service container. */
70
- dns_search?: ComposeString | Array<ComposeString>;
71
- /** Custom domain name to use for the service container. */
72
- domainname?: ComposeString;
73
- /** Override the default entrypoint declared by the container image, for example 'ENTRYPOINT' in Dockerfile. */
74
- entrypoint?: null | ComposeString | Array<ComposeString>;
75
- /** Add environment variables from a file or multiple files. Can be a single file path or a list of file paths. */
76
- env_file?: ComposeString | Array<ComposeString | { path: ComposeString; format?: ComposeString; required?: boolean | ComposeString }>;
77
- /** Add metadata to containers using files containing Docker labels. */
78
- label_file?: ComposeString | Array<ComposeString>;
79
- /** Add environment variables. You can use either an array or a list of KEY=VAL pairs. */
80
- environment?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
81
- /** Expose ports without publishing them to the host machine - they'll only be accessible to linked services. */
82
- expose?: Array<ComposeString | number>;
83
- /** Extend another service, in the current file or another file. */
84
- extends?: ComposeString | { service: ComposeString; file?: ComposeString };
85
- /** Specify a service which will not be manage by Compose directly, and delegate its management to an external provider. */
86
- provider?: { type: ComposeString; options?: Record<string, ComposeString | number | boolean | Array<ComposeString | number | boolean>>; [key: `x-${string}`]: unknown };
87
- /** Link to services started outside this Compose application. Specify services as <service_name>:<alias>. */
88
- external_links?: Array<ComposeString>;
89
- /** Add hostname mappings to the container network interface configuration. */
90
- extra_hosts?: Record<string, ComposeString | Array<ComposeString>> | Array<ComposeString>;
91
- /** Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of specific GPU devices. */
92
- gpus?: "all" | Array<{ capabilities?: Array<ComposeString>; count?: ComposeString | number; device_ids?: Array<ComposeString>; driver?: ComposeString; options?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString> }>;
93
- /** Add additional groups which user inside the container should be member of. */
94
- group_add?: Array<ComposeString | number>;
95
- /** Configure a health check for the container to monitor its health status. */
96
- healthcheck?: { disable?: boolean | ComposeString; interval?: ComposeString; retries?: number | ComposeString; test?: ComposeString | Array<ComposeString>; timeout?: ComposeString; start_period?: ComposeString; start_interval?: ComposeString; [key: `x-${string}`]: unknown };
97
- /** Define a custom hostname for the service container. */
98
- hostname?: ComposeString;
99
- /** Specify the image to start the container from. Can be a repository/tag, a digest, or a local image ID. */
100
- image?: ComposeString;
101
- /** Run as an init process inside the container that forwards signals and reaps processes. */
102
- init?: boolean | ComposeString;
103
- /** IPC sharing mode for the service container. Use 'host' to share the host's IPC namespace, 'service:[service_name]' to share with another service, or 'shareable' to allow other services to share this service's IPC namespace. */
104
- ipc?: ComposeString;
105
- /** Container isolation technology to use. Supported values are platform-specific. */
106
- isolation?: ComposeString;
107
- /** Add metadata to containers using Docker labels. You can use either an array or a list. */
108
- labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
109
- /** Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name. */
110
- links?: Array<ComposeString>;
111
- /** Logging configuration for the service. */
112
- logging?: { driver?: ComposeString; options?: Record<string, ComposeString | number | null>; [key: `x-${string}`]: unknown };
113
- /** Container MAC address to set. */
114
- mac_address?: ComposeString;
115
- /** Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes. */
116
- mem_limit?: number | ComposeString;
117
- /** Memory reservation for the container. */
118
- mem_reservation?: ComposeString | number;
119
- /** Container memory swappiness as percentage (0 to 100). */
120
- mem_swappiness?: number | ComposeString;
121
- /** Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap. */
122
- memswap_limit?: number | ComposeString;
123
- /** Network mode. Values can be 'bridge', 'host', 'none', 'service:[service name]', or 'container:[container name]'. */
124
- network_mode?: ComposeString;
125
- /** AI Models to use, referencing entries under the top-level models key. */
126
- models?: Array<ComposeString> | Record<string, { endpoint_var?: ComposeString; model_var?: ComposeString; [key: `x-${string}`]: unknown } | null>;
127
- /** Networks to join, referencing entries under the top-level networks key. Can be a list of network names or a mapping of network name to network configuration. */
128
- networks?: Array<ComposeString> | Record<string, { aliases?: Array<ComposeString>; interface_name?: ComposeString; ipv4_address?: ComposeString; ipv6_address?: ComposeString; link_local_ips?: Array<ComposeString>; mac_address?: ComposeString; driver_opts?: Record<string, ComposeString | number>; priority?: number; gw_priority?: number; [key: `x-${string}`]: unknown } | null>;
129
- /** Disable OOM Killer for the container. */
130
- oom_kill_disable?: boolean | ComposeString;
131
- /** Tune host's OOM preferences for the container (accepts -1000 to 1000). */
132
- oom_score_adj?: ComposeString | number;
133
- /** PID mode for container. */
134
- pid?: ComposeString | null;
135
- /** Tune a container's PIDs limit. Set to -1 for unlimited PIDs. */
136
- pids_limit?: number | ComposeString;
137
- /** Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'. */
138
- platform?: ComposeString;
139
- /** Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]). */
140
- ports?: Array<number | ComposeString | { name?: ComposeString; mode?: ComposeString; host_ip?: ComposeString; target?: number | ComposeString; published?: ComposeString | number; protocol?: ComposeString; app_protocol?: ComposeString; [key: `x-${string}`]: unknown }>;
141
- /** Init containers to run to completion before the service container is started. Each step runs in its own ephemeral container, in declared order; a non-zero exit fails the bring-up of the service and its dependents. */
142
- pre_start?: Array<{ command?: null | ComposeString | Array<ComposeString>; image?: ComposeString; user?: ComposeString; privileged?: boolean | ComposeString; working_dir?: ComposeString; environment?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; per_replica?: boolean | ComposeString; [key: `x-${string}`]: unknown }>;
143
- /** Commands to run after the container starts. If any command fails, the container stops. */
144
- post_start?: Array<{ command: null | ComposeString | Array<ComposeString>; user?: ComposeString; privileged?: boolean | ComposeString; working_dir?: ComposeString; environment?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; [key: `x-${string}`]: unknown }>;
145
- /** Commands to run before the container stops. If any command fails, the container stop is aborted. */
146
- pre_stop?: Array<{ command: null | ComposeString | Array<ComposeString>; user?: ComposeString; privileged?: boolean | ComposeString; working_dir?: ComposeString; environment?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; [key: `x-${string}`]: unknown }>;
147
- /** Give extended privileges to the service container. */
148
- privileged?: boolean | ComposeString;
149
- /** List of profiles for this service. When profiles are specified, services are only started when the profile is activated. */
150
- profiles?: Array<ComposeString>;
151
- /** Policy for pulling images. Options include: 'always', 'never', 'if_not_present', 'missing', 'build', or time-based refresh policies. */
152
- pull_policy?: ComposeString;
153
- /** Time after which to refresh the image. Used with pull_policy=refresh. */
154
- pull_refresh_after?: ComposeString;
155
- /** Mount the container's filesystem as read only. */
156
- read_only?: boolean | ComposeString;
157
- /** Restart policy for the service container. Options include: 'no', 'always', 'on-failure', and 'unless-stopped'. */
158
- restart?: ComposeString;
159
- /** Runtime to use for this container, e.g., 'runc'. */
160
- runtime?: ComposeString;
161
- /** Number of containers to deploy for this service. */
162
- scale?: number | ComposeString;
163
- /** Override the default labeling scheme for each container. */
164
- security_opt?: Array<ComposeString>;
165
- /** Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes. */
166
- shm_size?: number | ComposeString;
167
- /** Grant access to Secrets on a per-service basis. */
168
- secrets?: Array<ComposeString | { source?: ComposeString; target?: ComposeString; uid?: ComposeString; gid?: ComposeString; mode?: number | ComposeString; [key: `x-${string}`]: unknown }>;
169
- /** Kernel parameters to set in the container. You can use either an array or a list. */
170
- sysctls?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
171
- /** Keep STDIN open even if not attached. */
172
- stdin_open?: boolean | ComposeString;
173
- /** Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s'). */
174
- stop_grace_period?: ComposeString;
175
- /** Signal to stop the container (e.g., 'SIGTERM', 'SIGINT'). */
176
- stop_signal?: ComposeString;
177
- /** Storage driver options for the container. */
178
- storage_opt?: Record<string, unknown>;
179
- /** Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list. */
180
- tmpfs?: ComposeString | Array<ComposeString>;
181
- /** Allocate a pseudo-TTY to service container. */
182
- tty?: boolean | ComposeString;
183
- /** Override the default ulimits for a container. */
184
- ulimits?: Record<string, number | ComposeString | { hard: number | ComposeString; soft: number | ComposeString; [key: `x-${string}`]: unknown }>;
185
- /** Bind mount Docker API socket and required auth. */
186
- use_api_socket?: boolean;
187
- /** Username or UID to run the container process as. */
188
- user?: ComposeString;
189
- /** UTS namespace to use. 'host' shares the host's UTS namespace. */
190
- uts?: ComposeString;
191
- /** User namespace to use. 'host' shares the host's user namespace. */
192
- userns_mode?: ComposeString;
193
- /** Mount host paths or named volumes accessible to the container. Short syntax (VOLUME:CONTAINER_PATH[:MODE]) */
194
- volumes?: Array<ComposeString | { type: "bind" | "volume" | "tmpfs" | "cluster" | "npipe" | "image"; source?: ComposeString; target?: ComposeString; read_only?: boolean | ComposeString; consistency?: ComposeString; bind?: { propagation?: ComposeString; create_host_path?: boolean | ComposeString; recursive?: "enabled" | "disabled" | "writable" | "readonly"; selinux?: "z" | "Z"; [key: `x-${string}`]: unknown }; volume?: { labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>; nocopy?: boolean | ComposeString; subpath?: ComposeString; [key: `x-${string}`]: unknown }; tmpfs?: { size?: number | ComposeString; mode?: number | ComposeString; [key: `x-${string}`]: unknown }; image?: { subpath?: ComposeString; [key: `x-${string}`]: unknown }; [key: `x-${string}`]: unknown }>;
195
- /** Mount volumes from another service or container. Optionally specify read-only access (ro) or read-write (rw). */
196
- volumes_from?: Array<ComposeString>;
197
- /** The working directory in which the entrypoint or command will be run */
198
- working_dir?: ComposeString;
199
- /** A Compose extension field. The spec allows any `x-` key, and Compose itself ignores it. */
200
- [extension: `x-${string}`]: unknown;
201
- }
202
-
203
- /** A named volume definition in Docker Compose */
204
- export interface VolumeProps {
205
- /** Custom name for this volume. */
206
- name?: ComposeString;
207
- /** Specify which volume driver should be used for this volume. */
208
- driver?: ComposeString;
209
- /** Specify driver-specific options. */
210
- driver_opts?: Record<string, ComposeString | number>;
211
- /** Specifies that this volume already exists and was created outside of Compose. */
212
- external?: boolean | ComposeString | { name?: ComposeString; [key: `x-${string}`]: unknown };
213
- /** Add metadata to the volume using labels. */
214
- labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
215
- /** A Compose extension field. The spec allows any `x-` key, and Compose itself ignores it. */
216
- [extension: `x-${string}`]: unknown;
217
- }
218
-
219
- /** A network definition in Docker Compose */
220
- export interface NetworkProps {
221
- /** Custom name for this network. */
222
- name?: ComposeString;
223
- /** Specify which driver should be used for this network. Default is 'bridge'. */
224
- driver?: ComposeString;
225
- /** Specify driver-specific options defined as key/value pairs. */
226
- driver_opts?: Record<string, ComposeString | number>;
227
- /** Custom IP Address Management configuration for this network. */
228
- ipam?: { driver?: ComposeString; config?: Array<{ subnet?: ComposeString; ip_range?: ComposeString; gateway?: ComposeString; aux_addresses?: Record<string, ComposeString>; [key: `x-${string}`]: unknown }>; options?: Record<string, ComposeString>; [key: `x-${string}`]: unknown };
229
- /** Specifies that this network already exists and was created outside of Compose. */
230
- external?: boolean | ComposeString | { name?: ComposeString; [key: `x-${string}`]: unknown };
231
- /** Create an externally isolated network. */
232
- internal?: boolean | ComposeString;
233
- /** Enable IPv4 networking. */
234
- enable_ipv4?: boolean | ComposeString;
235
- /** Enable IPv6 networking. */
236
- enable_ipv6?: boolean | ComposeString;
237
- /** If true, standalone containers can attach to this network. */
238
- attachable?: boolean | ComposeString;
239
- /** Add metadata to the network using labels. */
240
- labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
241
- /** A Compose extension field. The spec allows any `x-` key, and Compose itself ignores it. */
242
- [extension: `x-${string}`]: unknown;
243
- }
244
-
245
- /** A config definition in Docker Compose */
246
- export interface DockerConfigProps {
247
- /** Custom name for this config. */
248
- name?: ComposeString;
249
- /** Inline content of the config. */
250
- content?: ComposeString;
251
- /** Name of an environment variable from which to get the config value. */
252
- environment?: ComposeString;
253
- /** Path to a file containing the config value. */
254
- file?: ComposeString;
255
- /** Specifies that this config already exists and was created outside of Compose. */
256
- external?: boolean | ComposeString | { name?: ComposeString };
257
- /** Add metadata to the config using labels. */
258
- labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
259
- /** Driver to use for templating the config's value. */
260
- template_driver?: ComposeString;
261
- /** A Compose extension field. The spec allows any `x-` key, and Compose itself ignores it. */
262
- [extension: `x-${string}`]: unknown;
263
- }
264
-
265
- /** A secret definition in Docker Compose */
266
- export interface DockerSecretProps {
267
- /** Custom name for this secret. */
268
- name?: ComposeString;
269
- /** Name of an environment variable from which to get the secret value. */
270
- environment?: ComposeString;
271
- /** Path to a file containing the secret value. */
272
- file?: ComposeString;
273
- /** Specifies that this secret already exists and was created outside of Compose. */
274
- external?: boolean | ComposeString | { name?: ComposeString };
275
- /** Add metadata to the secret using labels. */
276
- labels?: Record<string, ComposeString | number | boolean | null> | Array<ComposeString>;
277
- /** Specify which secret driver should be used for this secret. */
278
- driver?: ComposeString;
279
- /** Specify driver-specific options. */
280
- driver_opts?: Record<string, ComposeString | number>;
281
- /** Driver to use for templating the secret's value. */
282
- template_driver?: ComposeString;
283
- /** A Compose extension field. The spec allows any `x-` key, and Compose itself ignores it. */
284
- [extension: `x-${string}`]: unknown;
285
- }
286
-
287
- export const Service = createResource("Docker::Compose::Service", "docker", {}) as unknown as DockerResourceConstructor<ServiceProps>;
288
- export const Volume = createResource("Docker::Compose::Volume", "docker", {}) as unknown as DockerResourceConstructor<VolumeProps>;
289
- export const Network = createResource("Docker::Compose::Network", "docker", {}) as unknown as DockerResourceConstructor<NetworkProps>;
290
- export const DockerConfig = createResource("Docker::Compose::Config", "docker", {}) as unknown as DockerResourceConstructor<DockerConfigProps>;
291
- export const DockerSecret = createResource("Docker::Compose::Secret", "docker", {}) as unknown as DockerResourceConstructor<DockerSecretProps>;
292
-
293
- /** The Dockerfile instructions a step can name. FROM is the stage's own `from` field. */
294
- export type DockerfileInstructionName = "arg" | "env" | "run" | "copy" | "add" | "workdir" | "user" | "expose" | "volume" | "label" | "entrypoint" | "cmd" | "healthcheck" | "shell" | "stopsignal" | "onbuild";
295
- type DockerfileStepOf<K extends DockerfileInstructionName, V> = { [P in K]: V } & { [P in Exclude<DockerfileInstructionName, K>]?: never };
296
- /**
297
- * One Dockerfile instruction, named by its single key: `{ run: "npm ci" }` is `RUN npm ci`.
298
- * A string[] value (run, cmd, entrypoint, shell) is written in JSON exec form.
299
- */
300
- export type DockerfileStep =
301
- /** ARG: Build-time argument */
302
- | DockerfileStepOf<"arg", string>
303
- /** ENV: Environment variable */
304
- | DockerfileStepOf<"env", string>
305
- /** RUN: Run a command during build */
306
- | DockerfileStepOf<"run", string | string[]>
307
- /** COPY: Copy files from build context */
308
- | DockerfileStepOf<"copy", string>
309
- /** ADD: Add files (supports URLs and archives) */
310
- | DockerfileStepOf<"add", string>
311
- /** WORKDIR: Set working directory */
312
- | DockerfileStepOf<"workdir", string>
313
- /** USER: Set user for subsequent instructions */
314
- | DockerfileStepOf<"user", string>
315
- /** EXPOSE: Document exposed ports */
316
- | DockerfileStepOf<"expose", string | number>
317
- /** VOLUME: Create mount points */
318
- | DockerfileStepOf<"volume", string>
319
- /** LABEL: Add metadata labels */
320
- | DockerfileStepOf<"label", string>
321
- /** ENTRYPOINT: Set the entrypoint executable */
322
- | DockerfileStepOf<"entrypoint", string | string[]>
323
- /** CMD: Default command arguments */
324
- | DockerfileStepOf<"cmd", string | string[]>
325
- /** HEALTHCHECK: Health check instruction */
326
- | DockerfileStepOf<"healthcheck", string>
327
- /** SHELL: Set the shell for shell-form commands (JSON array form) */
328
- | DockerfileStepOf<"shell", string | string[]>
329
- /** STOPSIGNAL: Signal sent to stop the container */
330
- | DockerfileStepOf<"stopsignal", string>
331
- /** ONBUILD: Instruction to run when the image is used as a base */
332
- | DockerfileStepOf<"onbuild", string>;
333
- /**
334
- * One build stage: FROM, then its instructions.
335
- * Without `steps`, the per-kind fields are written in a fixed order: ARG, ENV, WORKDIR, USER, RUN, COPY, ADD, EXPOSE, VOLUME, LABEL, ENTRYPOINT, CMD, HEALTHCHECK.
336
- */
337
- export interface DockerfileStage {
338
- from: string;
339
- as?: string;
340
- /** Instructions after FROM, written exactly in this order. Can't be combined with the per-kind fields. */
341
- steps?: DockerfileStep[];
342
- /** ARG as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
343
- arg?: string[];
344
- /** ENV as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
345
- env?: string[];
346
- /** RUN as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
347
- run?: string[];
348
- /** COPY as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
349
- copy?: string[];
350
- /** ADD as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
351
- add?: string[];
352
- /** WORKDIR as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
353
- workdir?: string;
354
- /** USER as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
355
- user?: string;
356
- /** EXPOSE as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
357
- expose?: string[];
358
- /** VOLUME as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
359
- volume?: string[];
360
- /** LABEL as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
361
- label?: string[];
362
- /** ENTRYPOINT as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
363
- entrypoint?: string;
364
- /** CMD as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
365
- cmd?: string;
366
- /** HEALTHCHECK as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
367
- healthcheck?: string;
368
- }
369
- /**
370
- * A Dockerfile: `stages` for a multi-stage build, or `from` and the stage fields for one stage.
371
- * Without `steps`, the per-kind fields are written in a fixed order: ARG, ENV, WORKDIR, USER, RUN, COPY, ADD, EXPOSE, VOLUME, LABEL, ENTRYPOINT, CMD, HEALTHCHECK.
372
- */
373
- export interface DockerfileProps {
374
- name?: string;
375
- /** ARG instructions written before the first FROM, e.g. `["NODE_VERSION=20"]`. */
376
- globalArgs?: string[];
377
- from?: string;
378
- as?: string;
379
- stages?: DockerfileStage[];
380
- /** Instructions after FROM, written exactly in this order. Can't be combined with the per-kind fields. */
381
- steps?: DockerfileStep[];
382
- /** ARG as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
383
- arg?: string[];
384
- /** ENV as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
385
- env?: string[];
386
- /** RUN as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
387
- run?: string[];
388
- /** COPY as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
389
- copy?: string[];
390
- /** ADD as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
391
- add?: string[];
392
- /** WORKDIR as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
393
- workdir?: string;
394
- /** USER as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
395
- user?: string;
396
- /** EXPOSE as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
397
- expose?: string[];
398
- /** VOLUME as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
399
- volume?: string[];
400
- /** LABEL as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
401
- label?: string[];
402
- /** ENTRYPOINT as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
403
- entrypoint?: string;
404
- /** CMD as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
405
- cmd?: string;
406
- /** HEALTHCHECK as a per-kind field, written in the fixed order. Use `steps` to choose the order. */
407
- healthcheck?: string;
408
- }
409
-
410
- export const Dockerfile = createResource("Docker::Dockerfile", "docker", {}) as unknown as DockerResourceConstructor<DockerfileProps>;
@@ -1,4 +0,0 @@
1
- /**
2
- * Runtime factory constructors — re-exported from core.
3
- */
4
- export { createResource, createProperty } from "@intentius/chant/runtime";
@@ -1,99 +0,0 @@
1
- /**
2
- * Adapters bridging the docker-specific DockerParser/DockerGenerator
3
- * (which speak DockerIR / ParseResult / GenerateResult) to the core
4
- * TemplateParser / TypeScriptGenerator interfaces consumed by
5
- * `chant import` (packages/core/src/cli/commands/import.ts).
6
- *
7
- * The core import pipeline parses content into a TemplateIR (a flat list of
8
- * ResourceIR), optionally organizes resources into category files, then asks
9
- * the generator to emit GeneratedFile[]. We map each DockerIR to a ResourceIR
10
- * keyed by its `kind` (service/volume/network/config/secret/dockerfile) and
11
- * reverse the mapping in the generator so DockerGenerator can do the real work.
12
- */
13
-
14
- import type { TemplateIR, TemplateParser, ResourceIR, ParseContext } from "@intentius/chant/import/parser";
15
- import type { GeneratedFile, TypeScriptGenerator } from "@intentius/chant/import/generator";
16
- import { DockerParser, DockerfileParser, looksLikeDockerfile } from "./parser";
17
- import type { DockerIR, DockerfileStage, ParseResult } from "./parser";
18
- import { DockerGenerator } from "./generator";
19
-
20
- /** Convert a DockerIR into the core ResourceIR shape. */
21
- function dockerIrToResource(entity: DockerIR): ResourceIR {
22
- if (entity.kind === "dockerfile") {
23
- return {
24
- logicalId: entity.name,
25
- type: entity.kind,
26
- properties: { ...(entity.globalArgs ? { globalArgs: entity.globalArgs } : {}), stages: entity.stages },
27
- };
28
- }
29
- return {
30
- logicalId: entity.name,
31
- type: entity.kind,
32
- properties: entity.props,
33
- };
34
- }
35
-
36
- /** Convert a core ResourceIR back into a DockerIR for DockerGenerator. */
37
- function resourceToDockerIr(resource: ResourceIR): DockerIR {
38
- const name = resource.logicalId;
39
- switch (resource.type) {
40
- case "dockerfile":
41
- return {
42
- kind: "dockerfile",
43
- name,
44
- ...(Array.isArray(resource.properties.globalArgs) ? { globalArgs: resource.properties.globalArgs as string[] } : {}),
45
- stages: (resource.properties.stages as DockerfileStage[] | undefined) ?? [],
46
- };
47
- case "service":
48
- case "volume":
49
- case "network":
50
- case "config":
51
- case "secret":
52
- return {
53
- kind: resource.type,
54
- name,
55
- props: resource.properties,
56
- };
57
- default:
58
- // Unknown types from upstream organization are treated as services so
59
- // they still round-trip rather than being silently dropped.
60
- return { kind: "service", name, props: resource.properties };
61
- }
62
- }
63
-
64
- /**
65
- * TemplateParser adapter — wraps DockerParser.parse and maps its DockerIR
66
- * entities to a TemplateIR.
67
- */
68
- export class DockerTemplateParser implements TemplateParser {
69
- /** With `context.embedded`, a config's `content` another lexicon owns is handed to it (#3373). */
70
- parse(content: string, context?: ParseContext): TemplateIR {
71
- // A Dockerfile has no name of its own; it imports as `app`
72
- // (Dockerfile.app). Rename the export to choose the file name.
73
- if (looksLikeDockerfile(content)) {
74
- return { resources: [dockerIrToResource(new DockerfileParser().parse("app", content))], parameters: [] };
75
- }
76
- return dockerResultToTemplate(new DockerParser().parse(content, context));
77
- }
78
- }
79
-
80
- /** A compose parse result as the core TemplateIR. */
81
- export function dockerResultToTemplate({ entities, warnings }: ParseResult): TemplateIR {
82
- return {
83
- resources: entities.map(dockerIrToResource),
84
- parameters: [],
85
- ...(warnings.length > 0 ? { warnings } : {}),
86
- };
87
- }
88
-
89
- /**
90
- * TypeScriptGenerator adapter — converts a TemplateIR back into DockerIR[]
91
- * and delegates to DockerGenerator, returning a single generated file.
92
- */
93
- export class DockerTemplateGenerator implements TypeScriptGenerator {
94
- generate(ir: TemplateIR): GeneratedFile[] {
95
- const entities = ir.resources.map(resourceToDockerIr);
96
- const { source } = new DockerGenerator().generate(entities);
97
- return [{ path: "main.ts", content: source }];
98
- }
99
- }